<form class="a" id="b" v-if="a_show"></form>我的頁面上有很多這樣的表單,每一個都是通過一個v-if來手動控制顯示的。我想實現每當我這個a_show為true了,即表單出現時,滾動條自動滑到最底部,用vue.js。一開始想到watch,但是watch只能監視數據。所以應該怎么做呢?謝謝指導以下兩種都無效 created:function(){ window.onresize = function(){ if(document.getElementById('b')){ document.getElementById('b').scrollIntoViewIfNeeded(); } }; mounted:function(){ window.onresize = function(){ if(document.getElementById('b')){ document.getElementById('b').scrollIntoViewIfNeeded(); } };
用vue.js實現滑動條自動滑到底部
楊__羊羊
2018-12-19 17:18:15