Typescript + Vue + Element-ui
Typescript + Vue + Element-ui
如何在 Vue+typescript
中使用 element-ui
element-ui 没有类型,所以当我导入它时
import Vue from 'vue';
import Element from 'element-ui'
我收到一个错误
Could not find a declaration file for module 'element-ui'. '/home/andres/Code/cdr/frontend/node_modules/element-ui/lib/element-ui.common.js' implicitly has an 'any' type.
我该如何解决这个问题?
作为解决方法,您可以简单地创建自定义类型文件并声明模块:
// in element-ui.d.ts
declare module "element-ui";
这将导致您从 element-ui
导入的任何内容都被键入为 any
。当然,如果需要,您可以在 element-ui.d.ts
中添加类型定义以进行打字。
如何在 Vue+typescript
中使用 element-uielement-ui 没有类型,所以当我导入它时
import Vue from 'vue';
import Element from 'element-ui'
我收到一个错误
Could not find a declaration file for module 'element-ui'. '/home/andres/Code/cdr/frontend/node_modules/element-ui/lib/element-ui.common.js' implicitly has an 'any' type.
我该如何解决这个问题?
作为解决方法,您可以简单地创建自定义类型文件并声明模块:
// in element-ui.d.ts
declare module "element-ui";
这将导致您从 element-ui
导入的任何内容都被键入为 any
。当然,如果需要,您可以在 element-ui.d.ts
中添加类型定义以进行打字。