我有一个名为的方法changePlaceName
,我知道它正在工作,但是在我打电话getPlaces
查看更改后,我没有看到新的地名,而是在创建新地点时看到了名称。
这是changePlaceName
export function changePlaceName(placeId: u32, placeName: PlaceName): void {
assert(placeId >= 0, 'Place ID must be >= 0');
const place = Place.find(placeId);
logging.log(place.name); //gives "Galata Tower"
place.name = placeName;
logging.log(place.name); // gives "New Galata Tower"
}
我需要以某种方式保存它,但我不知道该怎么做。
我也试过这种方式;
export function changePlaceName(placeId: u32, placeName: string): void {
assert(placeId >= 0, 'Place ID must be >= 0');
const place = Place.find(placeId);
logging.log(place.name);
place.name = placeName;
let newPlace = storage.get<string>(placeName, 'new galata tower');
storage.set<string>(placeName, newPlace);
logging.log('New place is now: ' + newPlace);
}
现在我的视觉代码正在抱怨newPlace
内部storage.set
我如何解决它?