微信小程序移動拖拽視圖-movable-view實例詳解
更新時間:2019年08月17日 08:43:17 作者:北京智慧流官方iOS博客
這篇文章主要介紹了微信小程序移動拖拽視圖-movable-view的實例代碼,代碼簡單易懂,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
JS中的sender參數(shù)(sender是事件的傳值)前提是只有一個touch移動的時候。多個touch需要在
changedTouches
數(shù)組中查找
redclcik:function(sender){
wx.showModal({
title: '點擊紅色',
content: '',
})
console.log(sender);
},
redmove:function(sender){
console.log(sender);
// console.log(sender.changedTouches[0].pageX);
},
.wxss內(nèi)容:
<view>移動視圖控件</view> <!-- 創(chuàng)建一個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>
視圖效果:

總結(jié)
以上所述是小編給大家介紹的微信小程序移動拖拽視圖-movable-view實例詳解,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復(fù)大家的!
相關(guān)文章
JavaScript使用Base64編碼和Blob對象加密圖像url地址
有時候會看到一些網(wǎng)站的圖片src中是blob:http://example.com/7c672acb-375c-4a26-9af9-99cb4c77f04d,這樣的圖片加載怎么實現(xiàn)呢?本文講解在瀏覽器中JavaScript使用解析Base64編碼和Blob對象技術(shù)來實現(xiàn),下面是實現(xiàn)的步驟和相應(yīng)的示例代碼,2023-12-12

