DataV-Team / DataV-Vue3

WIP: DataV Vue3 + Vite + TypeScript
https://datav-vue3.jiaminghi.com/
MIT License
348 stars 44 forks source link

引入包@dataview/datav-vue3并挂载报错 #29

Open andrewgreat opened 1 year ago

andrewgreat commented 1 year ago

环境:webpack+vue3+ts

在main.ts文件中引入并挂载 import DataV from "@dataview/datav-vue3"; ... app.use(router).use(DataV, { classNamePrefix: "dv-" }); 有错误提示,运行时报错不能通过: import DataV 没有与此调用匹配的重载。 第 1 个重载(共 2 个),“(plugin: Plugin_2<[{ classNamePrefix: string; }]>, options_0: { classNamePrefix: string; }): App”,出现以下错误。 类型“typeof import("d:/workspace/study/dashboard/node_modules/@dataview/datav-vue3/es/index")”的参数不能赋给类型“Plugin_2<[{ classNamePrefix: string; }]>”的参数。 第 2 个重载(共 2 个),“(plugin: Plugin_2<{ classNamePrefix: string; }>, options: { classNamePrefix: string; }): App”,出现以下错误。 类型“typeof import("d:/workspace/study/dashboard/node_modules/@dataview/datav-vue3/es/index")”的参数不能赋给类型“Plugin_2<{ classNamePrefix: string; }>”的参数。ts(2769)

daidaihk commented 1 year ago

可以看看这个:http://t.csdn.cn/EuX68

andrewgreat commented 1 year ago

可以看看这个:http://t.csdn.cn/EuX68

按这个方法修改后又报这个错:Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/@dataview_datav-vue3.js?v=745ff770' does not provide an export named 'default' (at main.ts:4:8)

locagdgz commented 1 year ago

要改node_modules/@dataview/datav-vue3/package.json文件里的module项配置,从./es/index.js改为./es/index.mjs就好了。我的datav版本是0.0.0-test.1672506674342 vue版本是"vue": "^3.2.47",