下面的简单代码导致成千上万的警告日志:[esri.core.Promise] DEPRECATED:then() - 使用.when(callback,errback)代替。
简单代码:
异步函数test(){ const view = …
某些ArcGIS JS API类看起来像它们的实例呈现的承诺 then() 方法。
then()
看到 https://developers.arcgis.com/javascript/latest/guide/working-with-promises/#api-classes-as-promises
如果你返回异步函数的其中一个类的实例(或将它传递给promise解析器),那么promise会认为它实际上是一个新的promise并将它链接起来,好像你会做类似的事情一样 .then(() => new Promise()) 。
.then(() => new Promise())
的 解: 强>
将实例包装在数组或对象中以“隐藏” .then() 方法:
.then()
Promise.resolve([mapViewInstance])
Promise.resolve({mapViewInstance})
async function test() { return [mapViewInstance] }
的 初始反思: 强>
https://github.com/Esri/esri-loader/issues/101