JS中的sender參數(sender是事件的傳值)前提是只有一個touch移動的時候。多個touch需要在
changedTouches
數組中查找
redclcik:function(sender){ wx.showModal({ title: '點擊紅色', content: '', }) console.log(sender); }, redmove:function(sender){ console.log(sender); // console.log(sender.changedTouches[0].pageX); },
.wxss內容:
<view>移動視圖控件</view><!-- 創建一個move-area --><movable-area style="width:100%;height:1000rpx;background:gray;"> <!-- 可以移動view 黃色、寬高100rpx--> <movable-view style='background:yellow;width:100rpx;height:100rpx;' direction="all"> </movable-view> <!-- 可以移動view 紅色、寬高100rpx--> <movable-view style='background:red;width:100rpx;height:100rpx;' direction="all" bindtap='redclcik' bindtouchmove='redmove'> </movable-view></movable-area>
視圖效果:
總結
以上所述是小編給大家介紹的微信小程序移動拖拽視圖-movable-view實例詳解,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復大家的!
|
新聞熱點
疑難解答