taro 填坑之路taro 缓存
1.taro 缓存
/**
* 缓存数据 H5 小程序
* {food.id:{菜品信息 Num}, }
*/
import Taro from '@tarojs/taro';
// 取值
let store = Taro.getStorageSync(foodKey);
// 存值
Taro.setStorageSync(foodKey,store);
2.Array 的 some 和 filter
some 返回值为true/false
if(this.state.foodlist.some(item => item.pid == selectCata.id)){ // 返回值为true/false
//
}
filtern 返回值为筛选后的新数组
this.setState({
currentList: this.state.foodlist.filter(item => item.pid == selectCata.id) // 筛选
});
还没有评论,来说两句吧...