import Vue from 'vue'
import store from '../store'

export default (Vue) => {
    Vue.directive('power', {
        inserted: function (el, binding, vnode) {
            let power = binding.value
            if (power) {
                const arrAll = store.state.userInfo.Roles;
                let arr = [];
                arrAll.forEach(item => {
                    arr.push(item.name)
                })
                console.log(arr,'权限arr')
                // 是否拥有权限
                if (arr.indexOf(power) == -1) {
                    el.remove() //没有权限则删除模块节点
                }
            }
        }
    })
}
