当前位置:网站首页>Use uview to enable tabbar to display the corresponding number of tabbars according to permissions
Use uview to enable tabbar to display the corresponding number of tabbars according to permissions
2022-06-27 07:18:00 【Talking characters】
adopt uview Give Way tabbar Display the corresponding number of tabbar
finish building uview-app Shelves
Normal configuration page.json Of tabbar term
After the configuration is completed, pass vuex To control tabbar list The change of
The path in the above configuration must be preceded by /
index.js
import Vue from 'vue';
import Vuex from 'vuex'
Vue.use(Vuex)
const tabbar=[{
"pagePath": "/pages/index/index",
"iconPath": "/static/index.png",
"selectedIconPath": "/static/index-selected.png",
"text": " home page ",
"midButton": false,
}, {
"pagePath": "/pages/center/index",
"iconPath": "/static/center.png",
"selectedIconPath": "/static/center-selected.png",
"text": " I ",
"midButton": false,
},{
"pagePath": "/pages/perms/perms",
"iconPath": "/static/center.png",
"selectedIconPath": "/static/center-selected.png",
"text": " Permission page ",
"midButton": false,
}]
const store=new Vuex.Store({
state:{
tabbar_readonly:tabbar,
tabbar:tabbar
},
mutations:{
$uStore(state, payload) {
// Determine whether to call at multiple levels ,state The existence of objects in , Such as user.info.score = 1
let nameArr = payload.name.split('.');
let saveKey = '';
let len = nameArr.length;
if(nameArr.length >= 2) {
let obj = state[nameArr[0]];
for(let i = 1; i < len - 1; i ++) {
obj = obj[nameArr[i]];
}
obj[nameArr[len - 1]] = payload.value;
saveKey = nameArr[0];
} else {
// Single level variable , stay state It's just the case of an ordinary variable
state[payload.name] = payload.value;
saveKey = payload.name;
}
}
}
})
export default store
$u.mixin.js
import {
mapState
} from 'vuex'
import store from "@/store"
// Try to put the user's... In the root directory store/index.js Of vuex Of state Variable , Load all into global variables
let $uStoreKey = [];
try {
$uStoreKey = store.state ? Object.keys(store.state) : [];
} catch (e) {}
module.exports = {
created() {
// take vuex The method is hung to $u in
// Usage method: : If you want to modify vuex Of state Medium user.name Variable is " epic " => this.$u.vuex('user.name', ' epic ')
// If you want to modify vuex Of state Of version Variable is 1.0.1 => this.$u.vuex('version', '1.0.1')
this.$u.vuex = (name, value) => {
this.$store.commit('$uStore', {
name,
value
})
}
},
computed: {
// take vuex Of state All variables in , Deconstruction to global blending mixin in
...mapState($uStoreKey)
}
}
main.js
import store from './store/index.js'
const storeMixins = require('./store/$u.mixin.js');
Vue.mixin(storeMixins)
const app = new Vue({
store,
...App
})
app.$mount()
At every tabbar Used in pages u-tabbar Components
because vuex Medium state.tabbar It has been infiltrated globally , So each tabbar The page already has this.tabbar This variable .
In the component's list Attribute into tabbar Just go
边栏推荐
- poi导出excle
- 攻防演习防御体系构建之第一篇之介绍和防守的四个阶段
- [graduation season] graduation is the new beginning of your life journey. Are you ready
- Interviewer: do you have any plan to request a lot of data that does not exist in redis to destroy the database?
- SQL 注入绕过(一)
- mysql关于自增和不能为空
- What is the difference between volatile and synchronized?
- Solve the problem of win10 wsl2 IP change
- Transaction overview of tidb
- R 语言并行计算 spearman 相关系数,加快共现网络(co- occurrence network)构建速度
猜你喜欢
(已解决) MINet 进行测试时报错如下 raise NotImplementedError
Matlab GUI interface simulation DC motor and AC motor speed simulation
The fourth question of the 299th weekly match 6103 Minimum fraction of edges removed from the tree
Quick realization of Bluetooth ibeacn function
一个人管理1000台服务器?这款自动化运维工具一定要掌握
2022 cisp-pte (II) SQL injection
Memory barrier store buffer, invalid queue
vs怎么配置OpenCV?2022vs配置OpenCV详解(多图)
Centos7.9安装mysql 5.7,并设置开机启动
【编译原理】山东大学编译原理复习提纲
随机推荐
面试官:你天天用 Lombok,说说它什么原理?我竟然答不上来…
The song of cactus -- throwing stones to ask the way (1)
Vs how to configure opencv? 2022vs configuration opencv details (multiple pictures)
大学数据库mysql
From 5 seconds to 1 second, the system flies
tracepoint
vs怎么配置OpenCV?2022vs配置OpenCV详解(多图)
2018 mathematical modeling competition - special clothing design for high temperature operation
What is the difference between volatile and synchronized?
2022 CISP-PTE(一)文件包含
guava 定时任务
How torch.gather works
【OpenAirInterface5g】RRC NR解析之RrcSetupComplete
When there are multiple El select, the selected value is filtered by El select, and the last selected value is filtered by the second El select
Classical cryptosystem -- substitution and replacement
【毕业季】毕业是人生旅途的新开始,你准备好了吗
View functions in tidb
Winow10 installation nexus nexus-3.20.1-01
OpenCV怎么下载?OpenCV下载后怎么配置?
Talk about Domain Driven Design