如何在Angular 2 Webpack中使用WOW.js? [英] How to use WOW.js in Angular 2 Webpack?
本文介绍了如何在Angular 2 Webpack中使用WOW.js?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道我们需要wow.js的打字文件,但我无法在任何地方找到它。有没有其他解决方案将此外部js加载到webpack中?
I know we need typings file for wow.js but I couldn't find it anywhere. Is there any other solution for loading this external js into webpack?
推荐答案
执行以下步骤:
npm i exports-loader --save-dev
添加到
webpack.config.js
这个loader
webpack.config.js
this loader
{
test: require.resolve('wow.js/dist/wow.js'),
loader: 'exports?this.WOW'
}
在你的打字文件夹中创建
typings.d.ts
文件:
typings.d.ts
file in your typings folder:
declare module "wow.js/dist/wow.js" {
var noTypeInfoYet: any;
export = noTypeInfoYet;
}
添加导入到你的
* .component.ts
文件
import * as WOW from 'wow.js/dist/wow.js';
ngOnInit(){
new WOW().init();
}
当然,您可以使用自己的webpack配置,而无需 exports-loader
等...
Of course you can use your own webpack configuration without exports-loader
, etc...
这篇关于如何在Angular 2 Webpack中使用WOW.js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文