var keyName = 'myname';
var keyValue = 'qing';
//保存
AsyncStorage.setItem(keyName,keyValue,function(errs){
//TODO:错误处理
if (errs) {
console.log('存储错误');
}
if (!errs) {
console.log('存储无误');
}
});
//查看
var _this = this;
AsyncStorage.getItem(keyName,function(errs,result){
//TODO:错误处理
if (!errs) {
var num = parseInt(result, 10); //returns 10
console.log('result = '+num);
_this.setState({
text:'dafd'
});
console.log('result = '+_this.state.text);
}
});
//删除
AsyncStorage.removeItem(keyName,function(errs) {
if (!errs) {
console.log('移除成功');
}
});