Route with name ‘UserSet’ does not exist
我的路由配置:
path: '/user/UserSet/:id',
name: UserSet,
component: UserSet,
props: true
我的route-link:
<router-link :to="{name: 'UserSet',params: {id: 1}}">用户列表</router-link>
我的组件:
<template>
<div>
<h1>用户列表</h1>
<!--{{$route.params.id}}-->
{{id}}
</div>
</template>
<script>
export default {
props: ['id'],
name: "UserSet"
}
</script>
报错:
几经周折,发现问题原因,因为name的值是字符串,而不是一个变量,需要把name的值用单引号引起来,如果直接写,系统查不到。
这样问题自然就解决了,解决起来也很简单:
path: '/user/UserSet/:id',
name: 'UserSet',
component: UserSet,
props: true