小程序的movable-view怎么持續移動


在小程序的官方例子中,點擊按鈕以后的movable-view只是挪動了一次(鏈接:https://mp.weixin.qq.com/debug/wxadoc/dev/component/movable-view.html),那我想每點擊一次就再挪動一個距離怎么弄:

wxml:

<view class="section">
  <view class="section__title">movable-view區域小於movable-area</view>
  <movable-area style="height: 200px;width: 200px;background: red;">
    <movable-view style="height: 50px; width: 50px; background: blue;" x="{{x}}" y="{{y}}" direction="all">
    </movable-view>
  </movable-area>
  <view class="btn-area">
    <button size="mini" bindtap="taps">click me to move to (30px, 30px)</button>
  </view>

  js:

Page({
  data: {
    x:0,
    y:0
  },

  taps: function (e) {
    let num = 10;
    console.log(this.data.x);
    this.setData({
      x: this.data.x+num,
      y: this.data.x+num
    });
  }
})

  如此便可以實現功能了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM