hasPermission.js 951 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
const hasPermission = {
    install (Vue, options) {
        console.log(options);
          Vue.directive('has', {
            inserted: (el, binding, vnode)=>{
              //console.log("页面权限----",el);
              let permissionList = vnode.context.$route.meta.permissionList;
              if (permissionList === null || permissionList === "" || permissionList === undefined) {
                el.parentNode.removeChild(el)
              }
              let permissions = [];
              for (var item of permissionList) {
                permissions.push(item.action);
              }
              //console.log("页面权限----"+permissions);
              //console.log("页面权限----"+binding.value);
              if (!permissions.includes(binding.value)) {
                //if(el.parentNode)
                el.parentNode.removeChild(el)
              }
            }
          });
    }
};

export default hasPermission;