【发布时间】:2022-01-21 23:14:32
【问题描述】:
点击地图有错误触发时间。到达 Promise,null。解释为什么会这样?提前致谢:
onMapClick(e) {
if (e.latlng) {
this.post("/api/MapObjectItem/GetObjectInfoByLatLng", {
Lat: e.latlng.lat,
Lng: e.latlng.lng
}).then(result => {
if (this.jkh.isCreateEvent) {
this.jkh.selectedMessage = {
Address: result.Address,
Lat: result.Lat,
Lon: result.Lng,
UsersDataID: this.$auth.user.Id,
ObjectID: result.Id,
ToPublish: false
};
this.$refs.map.mapObject.setView([result.Lat, result.Lng], 18);
this.showDetails();
} else {
this.obj = result;
this.changeView();
}
});
}
【问题讨论】:
-
基本调试:在您的 .then() 回调中,输入
console.log(result)。 -
什么是
this.post?您如何处理 API 请求?什么图书馆? -
@DecadeMoon axios 库。
-
欢迎来到 Stack Overflow _“此错误承诺”不应作为图像链接发布 _ 您应该通过将错误消息复制/粘贴到代码块中来编辑您的帖子 _ 请花点时间访问 SO 帮助中心以了解有关发布问题的最佳方法的更多信息 >>> stackoverflow.com/help/asking
标签: javascript vue.js axios