我的問題與此類似。但我想將 async 關鍵字放在原型函數中,而不是構造函數中?!皌his”在原型函數 saySomething 中未定義。為什么?我如何在課堂上使用異步?var Person = function() { console.log("CALLED PERSON")};Person.prototype.saySomething = async () => { console.log(this);//undefined};(async function(){ var ape = new Person(); await ape.saySomething();}());
在異步原型函數中未定義 this
一只甜甜圈
2022-12-29 16:25:41