vux中tabbar数据记录问题

如何监控selected 呢?

比如说$router.path=='/'的时候再添加selected

<tabbar style="position:fixed;z-index:999">
  <tabbar-item selected link="/">
    <img slot="icon" src="../../static/bottom/home.png">
    <img slot="icon-active" src="../../static/bottom/home-ok.png">
    <span slot="label">首页</span>
  </tabbar-item>
  <tabbar-item @on-item-click="aaa" link="/shopping">
    <img slot="icon" src="../../static/bottom/shop.png">
    <img slot="icon-active" src="../../static/bottom/shop-ok.png">
    <span slot="label">商城</span>
  </tabbar-item>
  <tabbar-item link="/deal">
    <img slot="icon" src="../../static/bottom/trade.png">
    <img slot="icon-active" src="../../static/bottom/trade-ok.png">
    <span slot="label">交易</span>
  </tabbar-item>
  <tabbar-item link="/my">
    <img slot="icon" src="../../static/bottom/personal.png">
    <img slot="icon-active" src="../../static/bottom/personal-ok.png">
    <span slot="label">我的</span>
  </tabbar-item>
</tabbar>

clipboard.png

图标点击不同步

阅读 2.9k
2 个回答

给图片加判断的同时给文字也加上判断就可以了

<tabbar-item link="/">

<img v-if="$route.path==`/`" slot="icon" src="../../static/bottom/home-ok.png">
<img v-else slot="icon" src="../../static/bottom/home.png">
<span  v-if="$route.path==`/`" slot="label" style="color:#4caf50">首页</span>
<span v-else slot="label">首页</span>

</tabbar-item>

新手上路,请多包涵

但是 第一个 path 是无法被激活的 一直是灰色

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题