做了一个小程序的 movable-area 组件做的一个拖动功能,可能是我比较笨,逻辑我想了一个星期才有点起色,终于是 弄好了,
废话少说,上代码。
<view class="section">
<movable-area class="area" >
<movable-view class='cent' wx:for="{
{list}}" x="{
{item.x}}" y="{
{item.y}}"
data-index="{
{index}}" bindtouchstart='start' bindtouchend='end' bindtouchmove='move' direction="vertical">
{
{item.id}}</movable-view>
</movable-area>
</view>
.section{
width: 100%;
height: 100vh;
}
.area{
height: 100vh;
width: 100%;
background-color: white;
}
.cent{
color: white;
display: flex;
align-items: center;
justify-content: center;
background-color: #ccc;
border: solid 1rpx #7c7c7c;
height: 100rpx;
width: 99.5%;
}
// pages/test/test2.js
Page({