VUE custom command F5 will report to Failed to resolve directive:auth, after refreshing
the function I want to achieve is to obtain permissions after login, and then use the custom command to control whether the button is displayed. The code is as follows:
store.commit(types.RIGHT, res.body.myRight)
console.log(store.state.rights)
Vue.directive("auth",{
bind:function (el,binding) {
var isExist = false;
store.state.rights.forEach(function (item) {
if (item===binding.value) {
isExist =true
}
})
if (!isExist) {
el.parentNode.removeChild(el);
}
},
update:function (el,binding) {
var isExist = false;
store.state.rights.forEach(function (item) {
if (item===binding.value) {
isExist =true
}
})
if (!isExist) {
el.parentNode.removeChild(el);
}
}
}
)
this code exists after a successful login. Why do you have this problem every time you refresh the page with F5? I added UPDATE, but it"s useless. Still, there is a problem after refreshing. Ask God to answer it.