原因
我是在各个页面中引入的vant-tabbar,点击的时候虽然跳转了,但是双向绑定的v-model="activeName"的activeName并没有改变,所以只要改变activeName即可。
上代码
van-tabbar v-model="activeName">
<van-tabbar-item icon="home-o" replace to="/">首页</van-tabbar-item>
<van-tabbar-item icon="search" replace to="/about">阅读积分</van-tabbar-item>
<van-tabbar-item icon="friends-o" replace to="/invite">邀请发卡</van-tabbar-item>
<van-tabbar-item icon="setting-o" replace to="/sendarticle" >发文</van-tabbar-item>
<van-tabbar-item icon="todo-list-o" replace to="/myarticle">我的文章</van-tabbar-item>
<!-- A
b d
c # # e
# f
# h
# # -->
</van-tabbar>
</template>
<script>
export default {
name:'Tabbar',
data() {
return {
activeName: Number(sessionStorage.getItem('active')) || 0,
}
},
}
就在activeName中定义
created() {
sessionStorage.setItem('active',1)
},
在其他页面进行赋值即可