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根据用户权限去生成相应的选项卡数据

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

你改成这样

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

const route = useRoute();

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

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

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

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!