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) // 筛选
});

.

相关文章:

  • 2022-01-22
  • 2021-08-30
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案