【发布时间】:2021-10-28 10:25:17
【问题描述】:
我正在尝试在返回常量的函数中获取存储数据。但是,当没有设置存储时,应该使用不同的数据。
我遇到的问题是使用了“其他”数据,因为存储尚未返回信息。
在 .then() 中移动整个函数会导致问题:“声明类型既不是 'void' 也不是 'any' 的函数必须返回 value.ts”。我不知道应该如何解决。
generateMap(id: string, zoom: number): L.Map {
let current_position = {
latitude: 52.3702157,
longitude: 4.8951679
}
Storage.get({ key: 'current_position' }).then((result) => {
if (result.value != null) {
current_position = JSON.parse(result.value);
}
});
const map = L.map(id,
{
zoom: zoom,
center: latLng({ lat: current_position.latitude, lng: current_position.longitude }),
});
return map;
}
【问题讨论】:
标签: angular ionic-framework local-storage