async getMenuList() {
try {
const { menuList, actionList } = await this.$api.getPermissionList();
this.userMenu = menuList;
this.$store.commit("saveUserMenu", menuList);
this.$store.commit("saveUserAction", actionList);
} catch (error) {
console.error(error);
}
}
app.directive('has', {
beforeMount: (el, binding) => {
let actionList = storage.getItem('actionList')
let value = binding.value
let hasPermission = actionList.includes(value)
if (!hasPermission) {
el.style = 'display:none;'
setTimeout(() => {
el.parentNode.removeChild(el)
}, 0);
}
}
})
<el-button
@click="handleEdit(scope.row)"
size="mini"
v-has:add="'user-delete'"
>编辑</el-button>
<el-button
type="danger"
size="mini"
@click="handleDel(scope.row)"
v-has:add="'user-delete'"
>删除</el-button>