若使用require去引用.vue,
需在結尾加上default:
let routes=[
{
path:'/dashboard',
component:require('@/js/components/Dashboard.vue').default
},
...
]
否則可能會出現以下錯誤訊息:
[Vue warn]: Failed to mount component: template or render function not defined.
若是使用import的話就沒有這個問題:
import dashboard from '@/js/components/Dashboard.vue';
...
let routes=[
{
path:'/dashboard',
component:dashboard
},
...
]