我有一个用 asyncStorage 存储的项目列表,它们都有相同的键,使用await AsyncStorage.removeItem(key);
它删除整个项目列表的功能有没有办法只删除一个项目。
async removeItemValue(key) {
try {
await AsyncStorage.removeItem(key);
return true;
}
catch(exception) {
return false;
}
我将要做的:
就像是:
const value = await AsyncStorage.getItem(theKey);
if (value !== null){
var index = array.indexOf(theItem);
if (index > -1){
value.splice(index, 1);
}
}
AsyncStorage.setItem(theKey, value);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句