赞
踩
"tabBar": {
"custom": true,
"list": [
{
"pagePath": "pages/index/index"
},
{
"pagePath": "pages/my/index"
}
]
}
state: { pageValue: 0, pageList: [ { path: 'pages/index/index', text: '首页', icon: 'home' }, { path: 'pages/my/index', text: '我的', icon: 'account' }, ] }, getters: { pageList: state => state.pageList, pageValue: state => state.pageValue }, mutations: { SET_PAGE(state, data) { state.pageValue = data } }, actions: {}
<u-tabbar :value="pageValue" :fixed="true" :border="false" :placeholder="true" :safeAreaInsetBottom="true" > <u-tabbar-item v-for="item in pageList" :key="item.path" :icon="item.icon" :text="item.text" @click="clickPage(item)" /> </u-tabbar> import { mapGetters, mapMutations } from 'vuex' computed: { ...mapGetters(['pageValue']), ...mapGetters(['pageList']) }, methods: { ...mapMutations(['SET_PAGE']), // 注意参数必须是数组 clickPage(item) { this.SET_PAGE(index) // 这样写底部导航高亮才是正确的 uni.navigateTo({ url: item.path }) } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。