dhtmlxscheduler与Aurelia和打字稿

时间:2016-09-07 06:08:59

标签: typescript aurelia aurelia-cli

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

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';

2 个答案:

答案 0 :(得分: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>

答案 1 :(得分:0)

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

相反,import整个模块:

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

然后,您可以直接在班级中调用scheduler函数。

相关问题