【发布时间】:2019-08-17 11:15:05
【问题描述】:
我在尝试使用 Vue 路由器导入 Vue 组件时不断收到此错误。
这是我的main_app.js:
const Foo = { template: '<div>foo</div>' }
const Bar = { template: '<div>bar</div>' }
const Home = { template: '<div>Home</div>' }
const routes = [
{ path: '/foo', component: Foo },
{ path: '/bar', component: Bar },
{
path: '/home',
component: () => import('./list.vue')
}
]
const router = new VueRouter({
routes,
// mode: 'history'
})
const app = new Vue({
router
}).$mount('#app')
这是我的list.vue:
<template>
<div id="right"></div>
</template>
<script>
export default {
name: 'list',
data: function () {
return {
text: 'some-text'
}
}
}
</script>
尝试进行此更改,但它不起作用,我恢复了。
const router = new VueRouter({
routes, // short for `routes: routes`
// mode: 'history'
output: {
path: '/js',
filename: '[name].js',
chunkFilename: 'js/[id].[chunkhash].js',
publicPath: '/',
},
})
谢谢。
【问题讨论】:
-
你还能使用动态导入吗?因为如果你使用的是babel,语法解析需要这个插件link
-
我没有使用 babel。
标签: javascript vue.js vue-router