Parcourir la source

新增 自定义指令

wzh il y a 3 ans
Parent
commit
2553174c8e
2 fichiers modifiés avec 12 ajouts et 1 suppressions
  1. 9 0
      src/main.js
  2. 3 1
      src/views/accountManage/subAccountList.vue

+ 9 - 0
src/main.js

@@ -44,4 +44,13 @@ app.config.globalProperties.check = () => {
   console.log("check");
 };
 
+app.directive("auth", {
+  mounted(el, bind) {
+    let permissions = store.state.userPermission;
+    if (permissions.indexOf(bind.value) == -1) {
+      el.parentNode.removeChild(el);
+    }
+  },
+});
+
 app.use(router).use(ElementPlus).use(store).mount("#app");

+ 3 - 1
src/views/accountManage/subAccountList.vue

@@ -11,7 +11,9 @@
         ></el-input>
         <div class="seach-btn" @click="getSubAccountList">查询</div>
       </div>
-      <el-button type="primary" @click="visable = true">添加账号</el-button>
+      <el-button v-auth="'ADDPROXY'" type="primary" @click="visable = true"
+        >添加账号</el-button
+      >
     </div>
 
     <el-dialog