将Webpack从版本3升级到版本4和第三方软件包后,出现此错误:
[vue-router]无法解析默认的异步组件:TypeError:无法读取未定义的属性“ call”
[vue-router]路线导航期间未捕获的错误: TypeError:无法读取未定义的属性“调用” 在 webpack_require (引导程序:63)
Webpack.js
const ENV = process.env.NODE_ENV || 'production';
const path = require('path');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const conf = {
entry: {
'catalog/bonus': './app/Admin/assets/catalog/bonus/index.js'
},
output: {
filename: '[name].js',
path: `${__dirname}/public/assets/admin`,
publicPath: '/assets/admin/',
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@src': path.resolve(__dirname)
},
extensions: ['*', '.js', '.vue', '.json'],
},
plugins: [
new VueLoaderPlugin(),
],
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
},
],
},
};
if (ENV === 'development') {
conf.devtool = 'source-map';
}
module.exports = conf;
使用vue路由器的示例
import VueRouter from 'vue-router';
export default new VueRouter({
routes: [
{path: '/', name: 'main', component: () => import('./components/BonusList')},
{path: '/create', name: 'create', component: () => import('./components/BonusEdit')},
]
});
答案 0 :(得分:0)
根据documentation,VueRouter中的组件似乎不是函数,因此不可调用。而且,导入似乎返回undefined
时似乎无效。
您尝试过以下吗?
import VueRouter from 'vue-router';
import BonusList from './components/BonusList';
import BonusEdit from './components/BonusEdit';
export default new VueRouter({
routes: [
{path: '/', name: 'main', component: BonusList},
{path: '/create', name: 'create', component: BonusEdit},
]
});