首先先对文字写样式xcss

小程序导航栏 选中事件

然后写前台index.wxml

<view class="nav_wrapp">

<!--自己滚动-->

<scroll-view class="nav" scroll-x>

<view bindtap="activeNav" data-index="{{index}}" class="nav-item {{index===currentIndexnav?'active':''}}" wx:for="{{navList}}" wx:key="{{index}}">

{{item.navname}}

</view>

</scroll-view>

</view>

然后写index.js

data: {

//导航栏选中菜单索引

currentIndexnav:0,

//导航栏标签

navList: []

},

activeNav(e){

this.setData({

currentIndexnav:e.target.dataset.index

})

},

 

 

相关文章:

  • 2021-12-04
  • 2021-09-05
  • 2021-06-08
  • 2022-02-10
  • 2021-08-25
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-30
  • 2022-12-23
  • 2021-06-22
  • 2021-09-16
  • 2022-12-23
  • 2021-09-19
相关资源
相似解决方案