Skip to content

Instantly share code, notes, and snippets.

@vitorvargasdev
Created February 10, 2020 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vitorvargasdev/12a96eda8457bc80ec51a9dcb2dbba56 to your computer and use it in GitHub Desktop.
Save vitorvargasdev/12a96eda8457bc80ec51a9dcb2dbba56 to your computer and use it in GitHub Desktop.
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