微信小程序tab菜单切换实现选中效果 三元运算方法

2018-11-2809:01:59APP与小程序开发Comments2,368 views字数 403阅读模式

微信小程序tab菜单切换实现选中效果 用到三元运算方法文章源自菜鸟学院-https://www.cainiaoxueyuan.com/xcx/8078.html

wxml:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/xcx/8078.html

<view class='topmenu'>
<view wx:for="{{lmlist}}" data-id='{{item.id}}' class="taga-item-{{currentItem==item.id?'active-tag':''}}" bindtap="tagChoose">{{item.typename}}</view>
</view>
js:
  tagChoose: function (options) {
    var that = this
    var id = options.currentTarget.dataset.id;
    console.log(id)
    //设置当前样式
    that.setData({
      'currentItem': id
    })
  }
wxss:
.taga-item-active-tag{
  color: #d4237a
}
文章源自菜鸟学院-https://www.cainiaoxueyuan.com/xcx/8078.html
  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/xcx/8078.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定