這篇文章主要介紹了微信小程序頁(yè)面滾動(dòng)到指定位置代碼實(shí)例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
頁(yè)面上有一個(gè)元素或者組件,id 為 comment
則:
var me = this; var query = wx.createSelectorQuery().in(me); query.selectViewport().scrollOffset() query.select("#comment").boundingClientRect(); query.exec(function (res) { console.log(res); var miss = res[0].scrollTop + res[1].top - 10; wx.pageScrollTo({ scrollTop: miss, duration: 300 }); });以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注