两个 movable-view ,无法做到跟随移动
发布于 7 年前 作者 gangsong 13347 次浏览 来自 官方Issues

页面上有两个 movable-view      分别为 A , B

项目需求,拖拽A的时候,B也同时跟随A移动

实现的思路是在 A 上面bindchange事件,根据bindchange事件的坐标,同时setData给B,实现此效果

问题是A向B更新了自己的坐标(X,Y)数据后 B会延迟跟随A,延迟的时间500ms-1500ms 。

这个性能完全无法接受

正常情况下是B,是会同时跟随A的

请官方重视这个问题,为什么会这样呢?

<view class='container'>
 
 
<movable-area class="wrapper-header"  >
 
       <movable-view
       direction="horizontal"
        
       bindchange="change"
        
        >AAA</movable-view>
</movable-area>
 
   <!-- 我是分隔线 -->
 
<movable-area class="wrapper-header"  >
      <movable-view x="{{x1}}" y="{{y1}}" direction="horizontal" >BBB</movable-view>
</movable-area>
 
 
</view>
// components/calendarTable/calendarTable.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
 
  },
 
  /**
   * 组件的初始数据
   */
  data: {
 
    x1:0,
    y1:0,
 
  },
 
  /**
   * 组件的方法列表
   */
  methods: {
    change(e)
    {
        console.log(e.detail);
       let val=e.detail;
        this.setData({
          x1:val.x,
          y1:val.y
 
        })
    }
 
  }
})
2 回复

wxs第一次写不太好写,给你写个demo

https://developers.weixin.qq.com/s/ajm9XLmw79bM

不建议使用setdata的方式来执行这种高频操作。建议参考https://developers.weixin.qq.com/miniprogram/dev/framework/view/interactive-animation.html

回到顶部