import store from "@/store";
// 权限渲染
export const permission = {
  inserted: function (el, binding) {
    const { value } = binding;
    const roles = store.getters["user/userId"];
    if (value) {
      const permissionRoles = value;
      const hasPermission = permissionRoles.includes(roles);
      if (!hasPermission) {
        el.remove();
      }
    } else {
      throw new Error(`need roles! Like v-permission="['admin','editor']"`);
    }
  },
};
