点击icon改变颜色
发布于 5 年前 作者 yangzheng 13251 次浏览 来自 问答

想通过点击改变icon颜色

<view class=“amend-list-module  default_address” bindtap=“plus_active” wx:for="{{iconColor}}" style=“display:flex”>

               <icon type=“success” size=“15” color="{{item}}"/> 设为默认地址

  </view>

1 回复

已经解决了!

Page({

  data: {

    iconColor:"#b6abab",//自定义颜色

  },

 点击事件判断

plus_active:function(e){

      console.log(1)

      var bgColor = this.data.iconColor == ‘#b6abab’ ? ‘#ff8b91’ : ‘#b6abab’;

      this.setData( {

         iconColor: bgColor

      });

  }

回到顶部