<movable-area class = "movableArea" :style="{height:height + 'px'}"> <movable-view class="backHome" id="moveBtn" style="pointer-events: auto;" v-if = "drawStates" direction="all" out-of-bounds="false" :x="x" :y=y damping="18" @touchmove="moveStart" @touchend = "moveEnd" @click = "activityCenter"></movable-view> <movable-view class="movableView" id="moveBtn" style="pointer-events: auto;" v-else direction="all" out-of-bounds="false" :x="x" :y=y damping="18" @touchmove="moveStart" @touchend = "moveEnd" @click = "drawlottery"></movable-view> </movable-area> moveEnd (e) { let that = this; const query = wx.createSelectorQuery(); query.select("#moveBtn").boundingClientRect(); query.exec(function(res) { console.log(res[0].left,'位置')//获取元素距左侧距离 if ((res[0].left+23).toFixed()<= that.screenWidth/2) { that.x = 0 console.log(that.x) } else { that.x = that.screenWidth } that.y = res[0].top.toFixed() // setTimeout(() => { // },200) console.log(res[0].left,res[0].top,'顶部top值') console.log(that.x,that.y,'位置')//获取元素距左侧距离 }); },
小程序movable-view的x y赋值成功位置没有移动小程序movable-view的x y赋值成功位置没有移动
01-22