解决权限无法显示问题

This commit is contained in:
mkppo 2021-12-08 11:38:13 +08:00
parent 43b3956640
commit 509719a643

View File

@ -13,7 +13,8 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, inject, ref, watch } from "vue"; import { defineComponent, ref, watch } from "vue";
import { useCool } from "/@/cool";
export default defineComponent({ export default defineComponent({
name: "cl-menu-perms", name: "cl-menu-perms",
@ -28,7 +29,7 @@ export default defineComponent({
emits: ["update:modelValue"], emits: ["update:modelValue"],
setup(props, { emit }) { setup(props, { emit }) {
const service = inject<any>("service"); const { service } = useCool();
// //
const value = ref<any[]>([]); const value = ref<any[]>([]);
@ -67,21 +68,23 @@ export default defineComponent({
const col = (i: number, d: any[]) => { const col = (i: number, d: any[]) => {
const key = arr[i]; const key = arr[i];
const index = d.findIndex((e: any) => e.label == key); if (d) {
const index = d.findIndex((e: any) => e.label == key);
if (index >= 0) { if (index >= 0) {
col(i + 1, d[index].children); col(i + 1, d[index].children);
} else { } else {
const isLast = i == arr.length - 1; const isLast = i == arr.length - 1;
d.push({ d.push({
label: key, label: key,
value: key, value: key,
children: isLast ? null : [] children: isLast ? null : []
}); });
if (!isLast) { if (!isLast) {
col(i + 1, d[d.length - 1].children || []); col(i + 1, d[d.length - 1].children || []);
}
} }
} }
}; };