微信小程序文字滚动
startScroll() { let query = wx.createSelectorQuery() let last query.select('#box').scrollOffset() let getNowSrollLeft = function (cb) { query.exec(res => { cb(res[0].scrollLeft) }) } let scrollFn = () => { var now = this.data.scrollLeft + 1 this.setData({ scrollLeft: now }) getNowSrollLeft(scrollNum => {if (scrollNum === last) { this.setData({ scrollLeft: 0 }) } else { last = scrollNum } }) setTimeout(scrollFn, 100) }
scrollFn()
}
<scroll-view id='box' scroll-x class='g-scroll__contain' scroll-left="{{scrollLeft}}"> <view>发的阿斯蒂芬撒打算打是多大十大发十大阿萨打算地方阿萨德发的阿斯蒂芬撒打算打是多大十大发十大阿萨打算地方阿萨德</view> </scroll-view>
虽然功能实现了,但是有严重的问题,会导致页面上的点击事件失效