在开发过程中,我们使用 Printd 实现了要打印的页面。
创建插件/printd.ts
import Vue from "vue";
import { Printd } from "printd";
Vue.use(Printd);
nuxt.conifg.ts 的“插件”部分。
plugins: [
... ,
{ src: "~/plugins/printd", ssr: false }]
但错误如下所示
10:9 No overload matches this call.
Overload 1 of 2, '(plugin: PluginObject<unknown> | PluginFunction<unknown>, options?: unknown): VueConstructor<Vue>', gave the following error.
Argument of type 'typeof Printd' is not assignable to parameter of type 'PluginObject<unknown> | PluginFunction<unknown>'.
Property 'install' is missing in type 'typeof Printd' but required in type 'PluginObject<unknown>'.
Overload 2 of 2, '(plugin: PluginObject<any> | PluginFunction<any>, ...options: any[]): VueConstructor<Vue>', gave the following error.
Argument of type 'typeof Printd' is not assignable to parameter of type 'PluginObject<any> | PluginFunction<any>'.
Property 'install' is missing in type 'typeof Printd' but required in type 'PluginObject<any>'.
8 |
9 |
> 10 | Vue.use(Printd);
| ^
11 |
帮我!!
尝试添加:任何就像在下面。
import Vue from "vue";
import { Printd } from "printd";
Vue.use(Printd as any);
这可能就是你的答案。但如果这不起作用,试试这个。
import Vue from "vue";
const Printd = require("printd").Printd;
Vue.use(Printd);
...如果这仍然不起作用,试试这个。文件:~/types/index.d.ts
declare module "printd"
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句