简体   繁体   中英

Importing NPM-installed Libraries for Usage in Ember.js

Inside my component, I have

  didInsertElement: function() {

    $('#' + this.idVal).tokenfield({
      autocomplete: {
        source: ['red','blue','green','yellow','violet','brown','purple','black','white'],
        delay: 100,
        minLength: 1,
      },
      showAutocompleteOnFocus: true
    });

I am trying to use the npm package https://www.npmjs.com/package/bootstrap-tokenfield .

However, I noticed that $().tokenfield() is undefined meaning that I am not importing it properly. I tried adding it to the ember-cli-build.js but I noticed that it is probably importing bootstrap-tokenfield before jquery which causes issues. (Is this the case the ember.build.js imports those files before any dependencies?)

Am I supposed to import bootstrap-tokenfield in the component somehow if I am trying to use it with npm install?

I am using Ember 2.1.0.

如果您想导入npm软件包来嵌入客户端代码,则可以使用ember-browserify( https://github.com/ef4/ember-browserify ),在您的项目内部,您可以简单地执行

import MyCoolModule from "npm:my-cool-module";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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