简体   繁体   English

在JSPM中使用自定义Kendo-UI构建

[英]Using a custom Kendo-UI build with JSPM

I'm using KendoUI in my Aurelia application. 我在Aurelia应用程序中使用KendoUI。 So far, we are using the Grid control and the Autocomplete control. 到目前为止,我们正在使用Grid控件和Autocomplete控件。

Attempting to import the Kendo objects through ES6 (using System.JS and the import statement) has worked well with Kendo.all.min.js, as it exports a Kendo object with all of the namespaces. 尝试通过ES6导入Kendo对象(使用System.JS和import语句)已与Kendo.all.min.js配合良好,因为它会导出具有所有名称空间的Kendo对象。

My import statement from Kendo.all.min.js is as follows: 我从Kendo.all.min.js导入的语句如下:

import * as Kendo from 'kendo';

I can then use something like var datasource = new Kendo.data.dataSource() . 然后,我可以使用var datasource = new Kendo.data.dataSource() (I've set up my config.js to point 'kendo' to the correct file using the meta section.) (我已经设置了config.js,以使用meta部分将“ kendo”指向正确的文件。)

Kendo.all.min.js is quite large and most of the functionality is unnecessary. Kendo.all.min.js很大,大部分功能都是不必要的。 I thus created a Kendo.custom.min.js file with only the components that we're using. 因此,我仅使用我们正在使用的组件创建了Kendo.custom.min.js文件。 However, attempting to import Kendo through ES6 no longer works. 但是,尝试通过ES6导入剑道不再有效。 I no longer receive any usable properties on the imported object. 我不再在导入的对象上收到任何可用的属性。

How can I have a Kendo custom build work with ES6 imports? 如何将Kendo自定义构建与ES6导入一起使用?

I found the answer to this - it must be specified in config.js. 我找到了答案-必须在config.js中指定。

Because Kendo is an AMD package by default, JSPM (and other loaders like RequireJS) needs to know what it exports. 由于Kendo默认情况下是AMD软件包,因此JSPM(以及其他诸如RequireJS的加载程序)需要知道其导出的内容。 I had this in my JSPM configuration: 我的JSPM配置中包含以下内容:

  meta: {
    "vendor/kendo/kendo.custom.min.js": {
      "deps": [
        "github:components/jquery@2.1.4"
      ],
    }
  },

I had to change it by adding a line: 我必须通过添加一行来更改它:

  meta: {
    "vendor/kendo/kendo.custom.min.js": {
      "deps": [
        "github:components/jquery@2.1.4"
      ],
      "exports": "kendo"
    }
  },

...and it worked.I'm now seeing Kendo objects in my export. ...而且奏效了。我现在在导出中看到Kendo对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM