【问题标题】:Devextreme-intl localization messages not found in angular 5 app在 Angular 5 应用程序中找不到 Devextreme-intl 本地化消息
【发布时间】:2018-01-05 03:16:16
【问题描述】:

我正在对我的应用程序中的一些 devextreme 组件进行本地化。我决定用 devextreme-intl 来做这件事。我尝试导入消息时遇到问题。 我是这样写的:

import deMessages from 'devextreme/localization/messages/de.json';

但我收到一个错误:找不到模块“devextreme/localization/messages/de.json”。我检查了这个文件存在于节点模块中,所以我不知道问题是什么。 我正在尝试实现这样的目标: https://js.devexpress.com/Demos/WidgetsGallery/Demo/Localization/UsingIntl/Angular/Light/

【问题讨论】:

    标签: angular localization devextreme


    【解决方案1】:

    使用通配符模块名称

    在您的 TS 定义文件中,例如typings.d.ts,可以加这行:

    declare module "*.json" { const value: any; export default value; }

    来源:https://hackernoon.com/import-json-into-typescript-8d465beded79

    【讨论】:

      【解决方案2】:

      首先,将此添加到typings.d.ts

      declare module "*.json" {
          const value: any;
          export default value;
      }
      

      然后,将整个 json 文件导入成这样的字符串:

      import * as deMessages from 'devextreme/localization/messages/de.json';
      

      【讨论】:

        【解决方案3】:

        从 TyeScript 2.9 开始,您可以这样做:

        {
          "compilerOptions": {
            "resolveJsonModule": true,
            "esModuleInterop": true  
          }
        }
        

        (https://hackernoon.com/import-json-into-typescript-8d465beded79)

        【讨论】:

          猜你喜欢
          • 2017-08-31
          • 2019-10-25
          • 1970-01-01
          • 2014-07-04
          • 1970-01-01
          • 1970-01-01
          • 2020-01-19
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多