MR_Li紫
2016-05-11 15:51
Uncaught TypeError: Cannot read property 'ScrollTo' of undefined
这样看就很明显了
你看你的数组的右括号在哪里呢?你的function不能写在[]里面的。
define(['jquery'],function ($) { function ScrollTo(opts) { this.opts = $.extend({},ScrollTo.DEFAULTS,opts); this.$el = $('html,body'); } ScrollTo.prototype.move = function () { var opts = this.opts; this.$el.animate({ scrollTop:opts.dest },opts.speed); }; ScrollTo.prototype.go = function () { this.$el.scrollTop(this.opts.dest); }; ScrollTo.DEFAULTS = { dest:0, speed:500 }; return { ScrollTo:ScrollTo }; });
看到区别了吗?
define(['jquery',function($){
function ScrollTo(opts){
this.opts = $.extend({},ScrollTo.Defaults,opts);
this.$el = $('html,body');
};
ScrollTo.prototype.move = function(){
var opts = this.opts
this.$el.animate({scrollTop:opts.dest},opts.speed);
};
ScrollTo.prototype.go = function(){
this.$el.scrollTop(this.opts.dest);
};
ScrollTo.Defaults = {
dest:0,
speed:800
};
return {
ScrollTo : ScrollTo
};
}])
侧栏工具条开发
68226 学习 · 289 问题
相似问题