【问题标题】:dhtmlxscheduler with Aurelia and typescriptdhtmlxscheduler 与 Aurelia 和打字稿
【发布时间】:2016-09-07 06:08:58
【问题描述】:

我正在尝试将dhtmlxscheduler 安装到我的 Aurelia CLI (typescript) 应用程序中。我已经 npm 安装了它:

npm i dhtmlx-scheduler

然后我将它添加到aurelia.json 文件中:

{
  "name": "dhtmlx-scheduler",
  "path": "../node_modules/dhtmlx-scheduler/codebase",
  "main": "dhtmlxscheduler"
},

并为它创建了全局类型:

typings install dt~dhtmlxscheduler --global --save

一切都已安装,au run 编译正确。当我尝试实际使用该库时,虽然我收到此错误:

error TS2307: Cannot find module 'dhtmlxscheduler'.
[02:00:15] gulp-notify: [Error running Gulp] Error: src/components/appointments/appointments.ts(2,20): error TS2307: Cannot find module 'dhtmlxscheduler'.

我是这样导入的:

import * as scheduler from 'dhtmlxscheduler';

【问题讨论】:

  • 尝试将import * as scheduler from 'dhtmlxscheduler'; 更改为import * as scheduler from 'dhtmlx-scheduler';。 Aurelia CLI Github page 声明赋予“name”的值应该与导入中使用的值相同。

标签: typescript aurelia


【解决方案1】:

它适用于来自@Robinson Collado 的 import 语句。您可能希望将 dhtmlx-gantt css 文件添加为资源:

{
  "name": "dhtmlx-gantt",
  "path": "../node_modules/dhtmlx-gantt/codebase",
  "main": "dhtmlxgantt",
  "resources": [
    "dhtmlxgantt.css"
  ]
}

并将其包含在您的模板中:

<require from="dhtmlx-gantt/dhtmlxgantt.css"></require>

【讨论】:

    【解决方案2】:

    我查看了 dhtmlxscheduler.js,它没有 export 任何成员属性。执行import * as scheduler from 'dhtmlxscheduler'; 应该会给你一个错误。

    相反,import 整个模块:

    import 'dhtmlx-scheduler'; // Taking into account the comment that I left above
    

    然后你可以直接在你的类中调用scheduler函数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-18
      • 1970-01-01
      • 2016-09-17
      • 2017-09-26
      • 2021-01-02
      • 2020-02-02
      • 2020-07-25
      • 2016-09-16
      相关资源
      最近更新 更多