最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to install fastclick with ember-cli? - Stack Overflow

programmeradmin5浏览0评论

I've got an ember-cli project. I've used bower to install fastclick and have added it to my brocfile.

Now I'm trying to initialise it. In my app.js file I've added:

import FastClick from 'bower_ponents/fastclick/lib/fastclick';

But this gives me an error in the console: "Uncaught TypeError: Cannot read property 'default' of undefined". The inspector shows the following generated code:

["ember","ember/resolver","ember/load-initializers","bower_ponents/fastclick/lib/fastclick","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) {
"use strict";
 var Ember = __dependency1__["default"];
 var Resolver = __dependency2__["default"];
 var loadInitializers = __dependency3__["default"];
 var FastClick = __dependency4__["default"];      # chrome highlights this line

I assume the problem is that fastclick isn't patible with the ES6 loader that ember-cli uses. I don't have requirejs, so how can I install fastclick into my project? Docs are at .

I've also tried adding this to index.html, but it doesn't have any effect when I build an iOS app:

  $(function() {
    FastClick.attach(document.body);
  });

I've got an ember-cli project. I've used bower to install fastclick and have added it to my brocfile.

Now I'm trying to initialise it. In my app.js file I've added:

import FastClick from 'bower_ponents/fastclick/lib/fastclick';

But this gives me an error in the console: "Uncaught TypeError: Cannot read property 'default' of undefined". The inspector shows the following generated code:

["ember","ember/resolver","ember/load-initializers","bower_ponents/fastclick/lib/fastclick","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) {
"use strict";
 var Ember = __dependency1__["default"];
 var Resolver = __dependency2__["default"];
 var loadInitializers = __dependency3__["default"];
 var FastClick = __dependency4__["default"];      # chrome highlights this line

I assume the problem is that fastclick isn't patible with the ES6 loader that ember-cli uses. I don't have requirejs, so how can I install fastclick into my project? Docs are at https://github./ftlabs/fastclick.

I've also tried adding this to index.html, but it doesn't have any effect when I build an iOS app:

  $(function() {
    FastClick.attach(document.body);
  });
Share Improve this question asked Sep 17, 2014 at 11:19 jbrownjbrown 8,00618 gold badges77 silver badges127 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 9

With Ember-cli v0.0.42

Install fastclick with bower

bower install fastclick --save

In your Brocfile.js, add the following above module.exports = app.toTree();

app.import('bower_ponents/fastclick/lib/fastclick.js');

Then in your app.js you can add

var App = Ember.Application.extend({
  ...
  ready: function(){
    FastClick.attach(document.body);
  }
});

You'll also need to add "FastClick":true to your .jshintrc file's predefs, to prevent it from plaining. More info in the docs about Managing Dependencies.

You can also use ember-cli-fastclick :)

OK the jquery version didn't work, but putting the following in my index.html file did:

window.addEventListener('load', function() {
    FastClick.attach(document.body);
}, false);
发布评论

评论列表(0)

  1. 暂无评论