问题描述
我有与此帖子相同的问题=>
I have the same problem as this post => Finding the correct import for a third party DefinitelyTyped module
我正在尝试将 VanillaTilt 安装到我的Angular(TS)项目中.使用此 index.d.ts ...我保存了 d.ts
与 app.component.ts
相同的目录中,该目录如下所示:
I am trying to install VanillaTilt in to my Angular (TS) project. Using this index.d.ts... I saved that d.ts
in the same directory as app.component.ts
which looks like the following
import VanillaTilt from 'vanilla-tilt';
VanillaTilt.init(document.createElement('a'), { perspective: 1000 });
但是我得到以下ts错误 src/app/app.component.ts(3,8)中的错误:错误TS1192:模块"vanilla-tilt"没有默认导出.
but i get the following ts errorERROR in src/app/app.component.ts(3,8): error TS1192: Module '"vanilla-tilt"' has no default export.
我还尝试了此版本的> d.ts ,但我一直得到无法读取未定义的属性'init'
I also tried this version of the d.ts
but i kept getting Cannot read property 'init' of undefined
是否有人对在agular5中使用 VanillaTilt 有任何建议?
Does anyone have any advice on how to use VanillaTilt in agular5?
推荐答案
npm上现在可以使用键入.首先安装它们
Typings are available on npm now. First install them
npm install --save-dev @types/vanilla-tilt
然后删除您的本地.d.ts文件
Then remove your local .d.ts files
接下来,正确的导入语法是
Next, the correct syntax for importing is
import { VanillaTilt } from 'vanilla-tilt';
因为VanillaTilt具有命名出口,而不是默认出口.
Because VanillaTilt has a named export , not a default export.
这篇关于导入DefinitelyTyped模块angular的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!