taro 填坑之路(三)taro 缓存

1.taro 缓存

1
2
3
4
5
6
7
8
9
10
11
/**
 * 缓存数据 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

1
2
3
if(this.state.foodlist.some(item => item.pid == selectCata.id)){ // 返回值为true/false
  //
}

filtern 返回值为筛选后的新数组

1
2
3
this.setState({
  currentList: this.state.foodlist.filter(item => item.pid == selectCata.id) // 筛选
});

.

posted @   每天都要进步一点点  阅读(1111)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示