Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'matched') at Tagsbar.vue:8:14

接手了一个项目,用到了 vue。遇见报错:TypeError: Cannot read properties of undefined (reading ‘matched’) 问题。
描述:切换选项卡的时候,系统报错,如下图:

根据错误定位,找到代码:

用 console 打印后,发现除了第一次请求正常返回一些数据。其他点击事件返回的都是 undefined。不太懂 vue 的运行逻辑,求会解的大佬,答一下~

最佳答案

你改成这样

import { computed } from 'vue';
import { useRoute } from 'vue-router';

const route = useRoute();

const goroute = computed(() => {
  //TODO:
})

还有就是你的选项卡的数据来源是有误的。
建议你重构,通过 store 根据用户权限去生成相应的选项卡数据

10个月前 评论
wangxf (楼主) 10个月前
moqingab (作者) 10个月前
wangxf (楼主) 10个月前
讨论数量: 4

你改成这样

import { computed } from 'vue';
import { useRoute } from 'vue-router';

const route = useRoute();

const goroute = computed(() => {
  //TODO:
})

还有就是你的选项卡的数据来源是有误的。
建议你重构,通过 store 根据用户权限去生成相应的选项卡数据

10个月前 评论
wangxf (楼主) 10个月前
moqingab (作者) 10个月前
wangxf (楼主) 10个月前