JS中的sender參數(shù)(sender是事件的傳值)前提是只有一個(gè)touch移動(dòng)的時(shí)候。多個(gè)touch需要在
changedTouches
數(shù)組中查找
redclcik:function(sender){ wx.showModal({ title: '點(diǎn)擊紅色', content: '', }) console.log(sender); }, redmove:function(sender){ console.log(sender); // console.log(sender.changedTouches[0].pageX); },.wxss內(nèi)容:
<view>移動(dòng)視圖控件</view><!-- 創(chuàng)建一個(gè)move-area --><movable-area style="width:100%;height:1000rpx;background:gray;"> <!-- 可以移動(dòng)view 黃色、寬高100rpx--> <movable-view style='background:yellow;width:100rpx;height:100rpx;' direction="all"> </movable-view> <!-- 可以移動(dòng)view 紅色、寬高100rpx--> <movable-view style='background:red;width:100rpx;height:100rpx;' direction="all" bindtap='redclcik' bindtouchmove='redmove'> </movable-view></movable-area>
視圖效果:

總結(jié)
以上所述是小編給大家介紹的微信小程序移動(dòng)拖拽視圖-movable-view實(shí)例詳解,希望對(duì)大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會(huì)及時(shí)回復(fù)大家的!
新聞熱點(diǎn)
疑難解答
圖片精選