【问题标题】:How to use Globalize with Angular CLI如何通过 Angular CLI 使用 Globalize
【发布时间】:2020-09-01 02:44:45
【问题描述】:

如何在从 Angular cli 生成的 Angular 应用程序中加载 Globalize 库以及 CLDR 数据。当我执行以下步骤时:

  1. npm install globalize cldr-data
  2. import {Globalize} from 'globalize';app.component.ts
  3. ng serve

我收到此错误:

Can't resolve 'cldr' in '/Users/temp-user/cldr-app/node_modules/globalize/dist'
 @ ./~/globalize/dist/globalize.js 22:2-25:14
 @ ./~/globalize/dist/node-main.js
 @ ./src/app/app.component.ts
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

编辑:

还尝试将其包含在 scripts 中的 angular-cli.json

  "scripts": [
     "../node_modules/cldrjs/dist/cldr.js",
     "../node_modules/globalize/dist/globalize.js"
  ],

【问题讨论】:

  • 解决了吗?

标签: angular angular-cli globalize cldr


【解决方案1】:

仅仅包含任何库都不足以使用它,您需要在angular-cli.json文件中配置它。

"scripts": [
  ... path to global libraray
]

阅读更多关于Global Library Installation here的信息。

【讨论】:

  • 当我将它包含在scriptsangular-cli.json 中时,我仍然会收到该错误
  • @takeradi,你是否也在 cli-json 中添加了 cldrlibraray 的路径?
猜你喜欢
  • 2017-07-04
  • 1970-01-01
  • 2017-04-27
  • 2016-10-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-26
相关资源
最近更新 更多