我的代码:
var Backbone = require('backbone');
var $ = require('jquery');
Backbone.$ = $;
var velocity = require('velocity-animate');
module.exports = function (obj) {
var obj = obj || {};
return Backbone.View.extend({
tagName: 'article',
className: 'lab-notes__article--single',
initialize: function () {
var _this = this;
_this.collection.deferred.done(function () {
var _thePost = _this.collection.first();
_this.model = _this.collection.find(function(model) {
return model.get('slug') === data.slug;
});
_this.render();
});
},
render: function () {
var _this = this;
var data = this.model.attributes;
var JST = require('../templates/blog-post-single.html')(data);
this.$el.html(JST);
$('[data-blog-post-single]').html(this.el);
var openBlogPost = [
{ e: $('body'), p: 'scroll', o: { duration: 100, duration: 500, easing: 'easeInOutQuart', } },
{ e: _this.$el, p: 'fadeIn', o: { duration: 200 } }
];
$.velocity.RunSequence(openBlogPost);
}
});
};
…以及我在运行它时收到的错误:
Uncaught TypeError: Cannot read property 'RunSequence' of undefined
这发生在这一行:
$.velocity.RunSequence(openBlogPost);
我不确定发生了什么,但我觉得这与我对 Velocity 的需求有关。有什么建议么?