![](/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.