![](/img/trans.png)
[英]How do I get rid of this JS error: TypeError: $(…).validate is not a function
[英]how do I get rid of “with()” in this function?
因为不推荐使用with()
函数,所以我想在我的代码中删除它。
我怎么能在这个特定的功能中做到这一点?
(function(a,b){
for(a in b=a.prototype)with({d:b[a]})b[a]=function(c){d.apply(this,arguments);return this}
})(Element);
(function(a, b) {
for (a in b = a.prototype)
with({ d: b[a] })
b[a] = function(c) {
d.apply(this, arguments);
return this
}
})(Element);
其原因with
正在使用是关闭以上的值b[a]
的函数内,正确的替换是具有闭合:
(function(a, b) {
for (a in b = a.prototype)
(function (d) { //this line used to be: with({ d:b[a] })
b[a] = function(c) {
d.apply(this, arguments);
return this
}
}(b[a])); //this is where `d` is set
})(Element);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.