按钮权限
1 import { MessageBox } from 'element-ui'; 2 import store from '@/store/'; 3 4 export const checklogin = { 5 bind: (el, binding) => { 6 el.onclick = (e) => { 7 e.stopPropagation(); 8 const { userInfo } = store.state.user; 9 if (!userInfo) { 10 MessageBox.confirm('您尚未登录', '提示', { 11 confirmButtonText: '去登陆', 12 cancelButtonText: '取消', 13 type: 'warning', 14 callback: (action) => { 15 // eslint-disable-next-line no-unused-expressions 16 if (action === 'confirm') { 17 if (typeof binding.value === 'function') { 18 binding.value.call(this, binding.arg); 19 } 20 store.commit('changeLoginDialog', true); 21 } 22 }, 23 }); 24 } else if (typeof binding.value === 'function') { 25 binding.value.call(this, binding.arg); 26 } 27 }; 28 }, 29 };
按钮登录,自定义指令