收藏
回答

wx:if 设置无效,点击无法切换图标?

<image  wx:else   class="collectsrc="/images/collected.png"  bindtap="collectMusic"></image>

<image class="previous"  src="/images/previous.png"  bindtap="playPrevious"></image>

<image class="play"  wx:if="{{playState==0}}"   src="/images/play.pngbindtap="playMusic"></image>

<image class="play"  wx:elif="{{playState==1}}"   src="/images/pause.pngbindtap="playMusic" >

</image>

<image  wx:else    class="playsrc="/images/resume.png"   bindtap="playMusic"></image>




   data: {


        songName:"东京铁塔的幸福",

        singer:"江美琪",

        textLog:"",

        deviceId: "",

        name: "",

        allRes:"",

        serviceId:"",

        readCharacteristicId:"",

        writeCharacteristicId: "",

        notifyCharacteristicId: "",

        connected: true,

        canWrite: false,

        mtuSupport:false,

        playState: 0,

        collectState:false,

        playMode:0,

        count:-1,

        tally:-1,

        slider1: 50,

        slider2: 50,



    },





 playMusic:  async function(){

    var  playstatus=["playSong","pause","resume"]

    var that = this; 

    that.data.tally++;

    console.log("=======tally=======>" ,that.data.tally)

     ifthat.data.tally>2){

     that.data.tally=0;

     }

     let status=playstatusthat.data. tally];

    

      that.data.playState= that.data.tally;

      console.log("=======playState=======>" ,that.data.playState)


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

3 个回答

  • 矜持
    矜持
    2021-10-15

    改变data里的变量要用this.setData。 直接this.data是没有用的

    2021-10-15
    有用 1
    回复
  • 我可以弯腰
    我可以弯腰
    2021-10-15

    没有两个else ,是 if elif else

    2021-10-15
    有用
    回复
  • 小泽摔不倒
    小泽摔不倒
    2021-10-15

    你这个两个wx:else 前面的if呢

    2021-10-15
    有用
    回复
登录 后发表内容