vite动态导入问题
The above dynamic import cannot be analyzed by Vite.
See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#l
imitations for supported dynamic import formats. If this is intended to be left
as-is, you can use the /* @vite-ignore */ comment inside the import() call to su
ppress this warning.
今天遇到动态vite动态导入的问题记录一下
- “vue”: “^3.2.47”,
- “vite”: “^4.2.0”
- “vue-router”: “^4.1.6”,
/** 过去动态导入 */
component:() => import('../views/' + node.component)
/** vite中的新写法 */
// 1. 先引入
const modules = import.meta.glob("../views/**/**.vue");
// 2. 使用
component: modules['../views/' + node.component]
import.meta.glob
详情见