如何在test
回调中访问fadeOut()
?
slide(test) {
console.log("test before callback: ", test);
$(".class").fadeOut(1000, function(test) {
console.log("test after callback: ", test);
});
}
slide()
test before callback: Proxy {dispatchConfig: {…}, _targetInst: ReactDOMComponent, isDefaultPrevented: ƒ, isPropagationStopped: ƒ, _dispatchListeners: ƒ, …}
45my.js:17 test after callback: undefined
答案 0 :(得分:0)
从回调参数中删除test
,因为这遮住了最外面的test
参数。
查看此问题,了解有关JavaScript An example of variable shadowing in javascript
中的阴影的信息