有能力做到这一点
[a, b] = await function1(a, b)
但是当我这样做
[a, b] = await function1(a, b)
[a, b] = await function2(a, b)
我收到此错误消息
SyntaxError: Invalid left-hand side in assignment expression
[a, b] = await function1(a, b)
^
[a, b] = await function2(a, b)
我找到了一种解决方法,但想知道是否有一种方法可以使我的示例正常工作。
预先感谢
答案 0 :(得分:2)
您只需要在其中添加分号即可。它认为第二组 map.addSource("entries", {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": database-data-here
}
});
map.addLayer({
"id": "locations",
"type": "circle",
"source": "entries",
"paint": {
"circle-radius": 8,
"circle-color": "#41b9c1"
},
"filter": ["==", "$type", "Point"],
});
是同一表达式的一部分,更具体地说,它是数组索引。即,它看到了很多:
[a, b]
...然后想到“哇,我无法为[a, b] = await function1(a, b)[a, b] =
分配任何内容”
因此,请这样做:
await function1(a, b)[a, b]