10. fetch 网络层
//返回值text
response.text().then(function (text) {
console.log('response.text()='+ text);
});
9.async-storage 数据储存
import AsyncStorage from '@react-native-community/async-storage';
storeData = async () => {
try {
await AsyncStorage.setItem('@storage_Key', 'stored value')
} catch (e) {
// saving error
}
}
getData = async () => {
try {
const value = await AsyncStorage.getItem('@storage_Key')
if(value !== null) {
// value previously stored
}
} catch(e) {
// error reading value
}
}
8.SHA-256 加密使用
var hash = require('hash.js')
var hpw = hash.sha256().update(this.state.password).digest('hex')
7.基础用法
let strMap = new Map();
for (let k of Object.keys(res.data)) {
console.log(`k `+k);
console.log(`res[k]`+res.data[k]);
strMap.set(k,res.data[k]);
}
6.async 异步
async await配合使用 即可实现异步 async
5. 调试打log
react-native log-android
console.log('请求url: ', url);
4.JsonUtils 和字符串操作
3.查看version
npm info react-native
2.npmjs 资源库
1.报错异常
Install the library using either Yarn:
yarn add @react-native-community/netinfo
or npm:
npm install --save @react-native-community/netinfo