1.在main.js中添加以下代码
加在new vue之前
Vue
.directive('has', {
bind
: function (el
, binding
) {
if (!Vue
.prototype
.$_has(binding
.value
)) {
el
.style
.display
= 'none'
}
}
})
Vue
.prototype
.$_has = function (value
) {
let isExist
= false
let role
= store
.state
.d2admin
.user
.info
.role
if (role
=== value
) {
isExist
= true
}
return isExist
}
2.在需要控制的按钮上加v-has:
<el
-button v
-has
="parameter" style
="float: right" @click
="dialogForm(false)">新增
</el
-button
>
parameter处是自己项目的权限标识
转载请注明原文地址:https://tech.qufami.com/read-23417.html