安卓手机的web-view组件页内使用cover-view作浮窗按钮时,setData修改数据,页面不更新。ios正常·
<web-view src="">
<cover-view class="show w" bindtap="userClose" bindtouchmove="buttonMove" bindtouchstart="buttonStart" style="top:{{buttonTop}}rpx;left:{{buttonLeft}}rpx;">
<cover-image src="https://sales-dev.ihxlife.com/HuaPM_V/bcard/image/room/tool_show.png" class="user_show"></cover-image>
<cover-view class="text">显示</cover-view>
</cover-view>
</web-view>
js里setData修改buttonTop和buttonLeft,页面无变化,ios正常变化
buttonStart: function (e) {
console.log(777, e)
this.setData({
startPoint: e.touches[0]
})
//获取拖动开始点
},
buttonMove: function (e) {
console.log(666, e)
let rpx = this.data.rpx
var endPoint = e.touches[e.touches.length - 1] //获取拖动结束点
//计算在X轴上拖动的距离和在Y轴上拖动的距离
var translateX = endPoint.pageX - this.data.startPoint.pageX
var translateY = endPoint.pageY - this.data.startPoint.pageY
this.setData({
startPoint: endPoint
}) //重置开始位置
var buttonTop = this.data.buttonTop + translateY / rpx
var buttonLeft = this.data.buttonLeft + translateX / rpx
//判断是移动否超出屏幕
if (buttonLeft + 90 >= this.data.windowWidth) {
buttonLeft = this.data.windowWidth - 90;
}
if (buttonLeft <= 0) {
buttonLeft = 0;
}
if (buttonTop <= 0) {
buttonTop = 0
}
if (buttonTop + 138 >= this.data.windowHeight) {
buttonTop = this.data.windowHeight - 138;
}
this.setData({
// show: !this.data.show,
buttonTop: buttonTop,
buttonLeft: buttonLeft,
}, () => {
this.setData({
// show: !this.data.show,
})
})
console.log(233444555,this.data.buttonTop,this.data.buttonLeft)
},
那么多年了,提出同类的问题的人那么多,官方就不考虑下这种需求吗?