vue报错
Uncaught Error: [vue-router] route config "component" for path: /recommend cannot be a string id. Use an actual component instead.
在运行npm run dev命令时是没有问题的,但是在打开的页面里面是一片空白,打开控制台发现报错
componentString.png
该错误的翻译是
未捕获的错误:[vue-router]路由配置路径:/测试的“组件”不能是字符串id。 使用实际的组件出错原因:component: 'recommend' 。 组件名recommend不能加引号
`routes: [
{
path: '/recommend',
name: 'recommend',
component: 'Recommend',
},{
path:'/search',
name: 'search',
component:'Search',
},{
path:'/rank',
name: 'rank',
component:'Rank',
},{
path:'/singer',
name:'singer',
component:'Singer',
},
{
path:'tab',
name: 'tab',
component:'Tab',
}]`
所以之前写的组件id的引号都要去掉
去掉之后的代码为
routes: [ { path: '/recommend', name: 'recommend', component: Recommend, },![componentString.png](https://img.haomeiwen.com/i13948388/6a9baf15f8ce1abe.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) { path:'/search', name: 'search', component:Search, },{ path:'/rank', name: 'rank', component:Rank, },{ path:'/singer', name:'singer', component:Singer, }, { path:'tab', name: 'tab', component:Tab, }]
此时错误已经解决
网友评论