收藏
回答

小程序的e.currentTarget.dataset 的值1 放到数组当下标报错 1 没定义?

       


 <!--正面的框  -->

        <image src="https://www.chaochaotool.top:444/CQC/cow/01rice.pngmode="aspectFitclass="image-frontanimation="{{animation[1]}}bindtap='rotateFndata-id="1"></image>

        <!--背面的框  -->

        <image src="https://www.chaochaotool.top:444/CQC/cow/11rice.pngmode="aspectFitclass="image-backanimation="{{animation_back[1]}}"></image>

      </view>

      <!-- 2 -->

      <view class="main1">

        <image src="https://www.chaochaotool.top:444/CQC/cow/02happy.pngmode="aspectFitclass="image-frontanimation="{{animation[2]}}bindtap='rotateFndata-id="2"></image>

        <!--背面的框  -->

        <image src="https://www.chaochaotool.top:444/CQC/cow/12happy.pngmode="aspectFitclass="image-backanimation="{{animation_back[2]}}" ></image>



  rotateFn(e) {

    var id = parseInt(e.currentTarget.dataset.id)

    this.setData({

      id:id

    })

    console.log("反转ID:"+id)

    var Temp="animationMain["+id+"]"

      console.log("hope数组为"+Temp)


     var  backTemp="animationback["+id+"]"

     console.log("hope数组为"+backTemp)


    this.animation_main = wx.createAnimation({

        duration:400,

        timingFunction:'linear'

      })

      

      this.animation_back= wx.createAnimation({

        duration:400,

        timingFunction:'linear',

        

      })

    // 点击正面

    

      this.animation[id].rotateY(180).step()

      this.animation_back[id].rotateY(0).step()

      

      this.setData({

        //animationMain1: this.animation_main.export(),

        //animationBack1: this.animation_back.export(),

       // animationMain2: this.animation_main.export(),

        //animationBack2: this.animation_back.export(),

       // animationMain:[id]=this.animation[id].export(),

        //animation_back:[id]=this.animation_back[id].export(),

        [Temp]: this.animation_back.export(),

        [backTemp]:this.animation_back.export(),

      })

      

      console.log("id值修改为:"+this.data.id)

    //}

  },

回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容
问题标签