微信小程序之收藏view背景色以及文字状态的改变

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq939782569/article/details/86534652

上代码

<view class="detail-shoucang" style="background-color:{{BgColor}}" bindtap='shoucang'><text class="detail-shoucang.text">{{shoucang}}</text></view>
  </view>
.detail-shoucang{
  float: right;
  padding: 5rpx 15rpx;
}

.detail-shoucang.text{
 color: #fff;
  font-size: 28rpx;
  line-height: 51rpx;
}
 data: {
    BgColor: '#ff7315',
    shoucang:"收藏"
  }
shoucang: function(){
    var bgColor = this.data.BgColor == '#999999' ? '#999999' : '#999999';
    // 设置背景颜色数据
    this.setData({
      BgColor: bgColor,
      shoucang:"已收藏"
    });

  },

oK!

猜你喜欢

转载自blog.csdn.net/qq939782569/article/details/86534652
今日推荐