推 LERICAL: 在 function(event){} 開頭寫個 var that = this,然後 08/23 17:50
→ LERICAL: 後面都用 that 08/23 17:50
推 eggli: 關鍵字是this, binding, scope, javascript 08/23 18:14
推 SunNEET: 其實有ajax版XD 08/23 18:27
推 Sunal: 好ES6不用嗎 08/23 18:44
推 peanut97: 在success那裡的 function(response){} 改成(res)=>{} 08/23 18:54
→ peanut97: 使用ES6的Arror Function 就能避開this的問題 08/23 18:55
推 pilor: 有 Web版 08/23 19:35
→ iphoneX5566: 臉書有 JavaScript.tw 社團喔 08/23 20:10
→ ywbBetter: 全部改成await 08/23 22:37
→ arthur01832: 臉書也有Frontend Developers Taiwan喔 08/23 23:01
→ wonyeouuu: Function.prototype.bind 08/24 00:58
推 LoserWon: 想回答的都被講完了 看來強者都在這板 08/24 01:08
推 youuuuuli: 高手如雲 08/24 09:37
→ asleepme: 感謝高手大大們~ PTT的ajax跟web_design板看起來冷清 08/24 10:39
→ asleepme: 這裡的討論比較熱烈而且很有深度! 08/24 10:39
推 scps960740: 這是this bind的問題 因為axios的callback在執行的時 08/24 13:23
→ scps960740: 候this會指向window 在callback的後面加上.bind(this) 08/24 13:23
→ scps960740: 就可以綁定onclick的this了 08/24 13:23
→ scps960740: e.com.tw/m/articles/10193193 08/24 13:25
推 DolphinLinn: ES6 Arrow Function 綁定this 的scope 還有看到jq覺 08/27 08:58
→ DolphinLinn: 得頭很痛 看你要不要改document.querySelector 08/27 08:58
→ async: 都我的問題 08/27 09:30
推 pennymarkfox: asynchronize真的很整人,但也是很重要的基礎 08/28 17:28