简体   繁体   English

PrimeNG(PrimeUI)+ Webpack + angular2 +打字稿

[英]PrimeNG (PrimeUI) + Webpack + angular2 + typescript

Is here anybody who know how to make PrimeNG under Webpack working? 在这里有谁知道如何在Webpack下工作PrimeNG?

We have project on angular2-webpack-starter but the PrimeNG have todo just with System.js loader 我们在angular2-webpack-starter上有项目,但PrimeNG只使用System.js加载器

I get the point when the PrimeNG is loading fine, but i can get success with PrimeUI library... let say for example file primeng/components/togglebutton/togglebutton.ts 当PrimeNG加载正常时,我明白了,但我可以通过PrimeUI库获得成功...比如文件primeng/components/togglebutton/togglebutton.ts

error TS2503: Cannot find namespace 'PrimeUI'. 错误TS2503:找不到命名空间'PrimeUI'。

I even tried magic formula with declare in ...togglebutton.ts 我甚至尝试使用声明在...togglebutton.ts使用魔法公式

declare var PrimeUI:any;

and in my webpack.config 在我的webpack.config

plugins: [ 
  new webpack.ProvidePlugin({
    PrimeUI: 'primeui',
  })
  .
  .
 ],

but if I try something like 但如果我尝试类似的东西

import * as PrimeUI from 'primeui';

error TS2307: Cannot find module 'primeui'. 错误TS2307:找不到模块'primeui'。

I just remind I did npm install primeui and the primeui is present in node_modules with all dependencies 我只是提醒我做了npm install primeui ,并且primeui存在于node_modulesnode_modules具有所有依赖项

If you are getting error on : 如果您收到错误:

import * as PrimeUI from 'primeui';

You need to do 你需要这样做

declare module 'primeui' {
    var foo:any;
    export = foo
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM