Created
February 10, 2020 21:40
-
-
Save vitorvargasdev/12a96eda8457bc80ec51a9dcb2dbba56 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import store from '../store' | |
export default { | |
install (Vue) { | |
Vue.directive('permission', { | |
inserted (el, binding, vnode) { | |
if (binding.arg === 'can') { | |
let permission = store.state.user.permissions | |
if (permission !== []) { | |
if (permission.includes(binding.value)) { | |
return | |
} | |
vnode.elm.parentElement.removeChild(vnode.elm) | |
} | |
} else { | |
console.log(store.state.user.permissions) | |
} | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment