taro 填坑之路taro 缓存

你的名字 2021-03-28 15:22 984阅读 0赞

1.taro 缓存

  1. /**
  2. * 缓存数据 H5 小程序
  3. * {food.id:{菜品信息 Num}, }
  4. */
  5. import Taro from '@tarojs/taro';
  6. // 取值
  7. let store = Taro.getStorageSync(foodKey);
  8. // 存值
  9. Taro.setStorageSync(foodKey,store);

2.Array 的 some 和 filter

some 返回值为true/false

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

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

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

发表评论

表情:
评论列表 (有 0 条评论,984人围观)

还没有评论,来说两句吧...

相关阅读