Dus*_*tin 4 javascript safari jquery
我只收到一个Safari错误:TypeError:'...}附近表达式的结果.bind(this))...''[undefined]不是函数.
这些是第88-92行:
$(this.options.work).each(function(i, item) {
tmpItem = new GridItem(item);
tmpItem.getBody().appendTo($("#" + this.gridId));
this.gridItems.push(tmpItem);
}.bind(this));
Run Code Online (Sandbox Code Playgroud)
是什么原因引起了这个?
mu *_*ort 10
较旧版本的Safari不支持bind.如果你试试这个(http://jsfiddle.net/ambiguous/dKbFh/):
console.log(typeof Function.prototype.bind == 'function');
Run Code Online (Sandbox Code Playgroud)
你将获得false较旧的Safaris,但true最新的Firefox和Chrome.我不确定Opera或IE,但有一个兼容性列表(可能是也可能不准确):
您可以尝试在修补你自己的版本是这样的:
Function.prototype.bind = function (bind) {
var self = this;
return function () {
var args = Array.prototype.slice.call(arguments);
return self.apply(bind || null, args);
};
};
Run Code Online (Sandbox Code Playgroud)
但请检查是否Function.prototype.bind有第一个.
| 归档时间: |
|
| 查看次数: |
3337 次 |
| 最近记录: |