【報錯】
Uncaught Error:
[vue-router] route config "component" for path: /home cannot be a string id.
Use an actual component instead
運行時不報錯,但是頁面顯示空白。打開控制台顯示下圖:
.
【報錯解析】
路徑/home的[vue router]route config“component”不能是字符串id 請改用實際的組件
在以下代碼中定位,可以看到是組件的錯誤component
export default new Router({ routes: [ { path:'/', redirect:'/home' }, { path:'/home', component:'Home' }, { path:'/cart', component:'Cart' }, { path:'/profile', component:'Profile' } ] })
發現 component:'Profile' 不能加引號
【解決方法】
去掉引號(component:Profile)后界面即可正常顯示。