/**
 * is me
 * getStorageContent
 * ××平台 获取缓存里面的值为string 需要做换
 */
const storageJd = Taro.getStorageSync;
const getStorageValue = (item) => {
  const keyValue = storageJd(item)
  // console.log('Taro.getSystemInfoSync()', Taro.getSystemInfoSync())
  // const isIos = Taro.getSystemInfoSync().system.toUpperCase().indexOf('IOS') >= 0 ? true : false //判断是否为ios 真机OK 模拟器报错
  // console.log('isIos:',isIos)
  if (process.env.TARO_ENV === '××') { 
    try {
      const value = keyValue ? JSON.parse(keyValue) : ''; // 能转则转 不能转返回自身
      console.log('转化之后的value为:', value)
      console.log('类型:', typeof (value))
      return value
    } catch (error) {
      return keyValue
    }
  } else {
    return keyValue
  }
  
}
Taro.getJdStorageSync = getStorageValue;
Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐