import store from '../store'
// 新建js
export default {
install(app) {
// 权限控制, 没有相关的权限, 则删除模块
app.directive('permission', {
mounted(el, val) {
if(el && !store.state.rule.includes(val.value)) {
el.parentNode && el.parentNode.removeChild(el)
}
}
})
}
}
main.js
import directives from './directives'
app.use(directives)
组件里使用
<section v-permission="'1234'">标签:el,自定义,directive,permission,app,directives,vue3,store From: https://www.cnblogs.com/anans/p/17279709.html
permission--permission
</section>