Dou*_*ell 5 javascript typescript semantic-ui vue.js vuejs2
Semantic-UI-Vue我正在尝试在我的 vue 项目中使用。但是,当我尝试执行以下操作时,出现以下错误Vue.use(SuiVue):
'typeof import("semantic-ui-vue")' 类型的参数不可分配给 'PluginObject<{}> | 类型的参数 PluginFunction<{}>'。\n 类型 'typeof import("semantic-ui-vue")' 不可分配给类型 'PluginFunction<{}>'。\n 类型 'typeof import("semantic-ui-vue" )' 没有提供与签名 '(Vue: VueConstructor, options?: {} | undefined): void' 的匹配。”
我创建了一个.d.ts文件,可以让我导入 SuiVue:
declare module 'semantic-ui-vue'{}
Run Code Online (Sandbox Code Playgroud)
我将其导入到我的app.tsas 中:
import * as SuiVue from 'semantic-ui-vue';
Run Code Online (Sandbox Code Playgroud)
我需要做什么才能让这个插件在 TypeScript 项目中可用,而不禁用全局 TypeScript 设置,例如noImplicitAny?
declare module 'semantic-ui-vue'{}用。。。来代替declare module 'semantic-ui-vue';
declare module 'semantic-ui-vue'{}表示该模块具有空对象类型{}。
declare module 'semantic-ui-vue';表示模块的类型为any
请参阅https://www.typescriptlang.org/docs/handbook/modules.html中的速记环境模块
正如OP所指出的,您需要更改导入语句才能import SuiVue from 'semantic-ui-vue';使其工作
| 归档时间: |
|
| 查看次数: |
5546 次 |
| 最近记录: |