VUE3+element-plus如何在组件内动态加载element-plus组件?-灵析社区

云卿山手

系统使用了element-plus按需载入的方式 ![image.png](https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20241127/21f8e36661c87abb1b390de3c998806c.png) 我需要在一个组件内动态加载某些组件 async function loader(type: keyof typeof Modules) { return defineAsyncComponent({ loader: () => import('element-plus')['ElInput'] }) } 这个loader方法一直无法正确渲染相应组件,例如type传入“ELInput”时系统会报个警告 [Vue warn]: Component is missing template or render function. at at at at at at at ref=Ref key="/home/fuck" > at at at at at at at at ref=Ref > at at at 尝试过`import('element-plus/lib/components/ElInput')`这种写法页不行,报错:`[plugin:vite:import-analysis] No known conditions for "./lib/components/ElInput" specifier in "element-plus" package` 求大神指导

阅读量:92

点赞量:0

问AI
你好我叫张倩话
建议改为 计算属性,因为涉及异步加载组件,我这边有实现加载成功