问题 :
router路由使用懒加载
本地打包正常
线上打包报错, router找不到对应文件
解决 :
找了很多方案, 最后找到一位作者的方法, 成功了
// router/index.js
import { defineAsyncComponent } from 'vue'
const _import = (path) => defineAsyncComponent(() => import(`../views/${path}.vue`));
const routes = [
{
path: '/async-component',
name: 'asyncComponent',
component: _import('home'),
}
];
使用vue3提供的异步引入