简体   繁体   中英

Ember-Cli import js without bower

I should import this plug-in that is not present in bower: ImageTiltEffect , in my ember-cli app. I already created the sub-directory in the vendor directory, imported this in my Brocfile and added "TiltFx": true in my .jshintrc file. About the last point I am not very sure if it is done in the right way, btw my question is: after these steps, how can I use this plug-in? How can I call its init function from my ember code? Thank you in advance for the answers!

Import the library in ember-cli-build.js:

app.import('vendor/tiltfx.js');
return app.toTree();

In your .jshintrc file, add TiltFx as a predefined global:

"predef": [
  "document",
  "window",
  "-Promise",
  "TiltFx"
],

You should now be able to use TiltFx.

component.js

onDidInsertElement: function() {
  new TiltFx(element, options)
}.on('didInsertElement'),

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