码迷,mamicode.com
首页 > 微信 > 详细

微信小程序-bindtap事件子元素不传参

时间:2018-02-08 20:03:12      阅读:452      评论:0      收藏:0      [点我收藏+]

标签:back   ret   改变样式   data   body   round   rip   highlight   ffffff   

 
<ul id="tabBar">
    <li class="{{currentTabBar_s == 10?‘active‘:‘‘}}" data-current="10" bindtap="swichTabN"><image src=‘../../images/icon/tab_MyTodo_s.png‘ class=‘img_s‘></image><image src=‘../../images/icon/tab_MyTodo.png‘ class=‘img_n‘></image><span>待办</span></li>
    <li class="{{currentTabBar_s == 11?‘active‘:‘‘}}" data-current="11" bindtap="swichTabN"><image src=‘../../images/icon/tab_Customers.png‘ class=‘img_n‘></image><image src=‘../../images/icon/tab_Customers.png‘ class=‘img_s‘></image><span>客户</span></li>
    <li class="{{currentTabBar_s == 12?‘active‘:‘‘}}" data-current="12" bindtap="swichTabN"><image src=‘../../images/icon/tab_Find.png‘ class=‘img_n‘></image><image src=‘../../images/icon/tab_Find.png‘ class=‘img_s‘></image><span>发现</span></li>
    <li class="{{currentTabBar_s == 13?‘active‘:‘‘}}" data-current="13" bindtap="swichTabN"><image src=‘../../images/icon/tab_Achieve.png‘ class=‘img_n‘></image><image src=‘../../images/icon/tab_Achieve.png‘ class=‘img_s‘></image><span>业绩</span></li>
  </ul>

  技术分享图片

 

 // 点击标题切换当前页时改变样式
  swichTabN: function (e) {
    var _this=this;
   var cur = e.target.dataset.current;    
 
  //点击li的子级元素,不进行值改变,解决方法把取值方式  由e.target.dataset.current;  修改为e.currentTarget.dataset.current即可
    var cur = e.currentTarget.dataset.current;
    console.log(_this.data.currentTabBar_s)
    console.log(_this.data)
    if (this.data.currentTabBar_s == cur) { console.log(123);return false; }
    else {
      console.log(5687)
      this.setData({
        currentTabBar_s: cur
      })
    }
  },

  

微信小程序-bindtap事件子元素不传参

标签:back   ret   改变样式   data   body   round   rip   highlight   ffffff   

原文地址:https://www.cnblogs.com/jiayeyuan/p/8432407.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!