首页 文章

如何整合Ionic 3和Angular材料?

提问于
浏览
0

我正在尝试使用Angular Material集成和运行Ionic 3,但未能做到这一点 . ......任何人都可以告诉我如何向Ionic添加第三方 . 以及如何在Ionic Framework中运行Angular Material . .....我做的是以下::

  • 我安装了 @angular/material, @angular/cdk@angular/animations .

使用以下内容在config文件夹中添加 copy.config.js 文件::

copyMaterialThemeCSS:{src:['{} / node_modules/@angular/material/prebuilt-themes/indigo-pink.css'],dest:'{} / assets'}

-Edit in Package.json 添加以下内容:

“config”:{“ionic_copy”:“ . / config / copy.config.js”}

-in Index.html我添加了这一行:

<link href="assets/indigo-pink.css" rel="stylesheet">
  • 最后,当从Angular Material添加任何组件时,我收到此错误:
TypeError: Object(...) is not a function
    at http://localhost:8100/build/vendor.js:138867:128
    at Object.<anonymous> (http://localhost:8100/build/vendor.js:138869:2)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.<anonymous> (http://localhost:8100/build/vendor.js:135975:76)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.<anonymous> (http://localhost:8100/build/vendor.js:147347:81)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.218 (http://localhost:8100/build/main.js:116:82)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.195 (http://localhost:8100/build/main.js:96:70)

...

先感谢您 .

1 回答

  • 0

    我从youtube上听了这个回答并解决了我的问题:

    检查package.json是否具有Angular Material和Angular CDK包的以下条目: - “@ angular / cdk”:“^ 5.2.4”, - “@ angular / material”:“^ 5.2.4”如果你看到一个5.2.4以上的版本你正在使用angular 5尝试使用那些commandes'降级'=> npm uninstall @ angular / material --save然后npm install @ angular / material @ 5.2.4 --save and对于CDK使用:=> npm uninstall @ angular / cdk --save然后npm install @ angular / cdk @ 5.2.4 --save

相关问题