Closed wkh2 closed 1 year ago
兼容性问题,import {getStorageSync} from '@tarojs/taro' 即可解决,不要使用import Taro from '@tarojs/taro'.,Taro. getStorageSync. 希望能帮到你
哥,还是有问题啊,都2023年了 还没解决吗。。
import {getStorageSync} from '@tarojs/taro-h5'可以; 但是Taro本身就是一个跨端编译的框架,这样搞不是坑吗。。 import {getStorageSync} from '@tarojs/taro' 就不行。
相关平台
微信小程序
复现仓库
https://git.jd.com/wanghui278/apl-taro-nbyh.git 小程序基础库: Google Chrome Google Chrome 已是最新版本 版本 92.0.4515.107(正式版本) (x86_64) 使用框架: React
复现步骤
解压demo 执行 ➜ rm -rf node_modules package-lock.json
然后执行 npm i npm run dev:h5 即可复现
期望结果
页面正常渲染,无报错
实际结果
页面有报错 Uncaught TypeError: i.getStorageSync is not a function at c.value (index.umd.js?c52c:1) at callComponentWillMount (react-dom.development.js?61bb:12784) at mountClassInstance (react-dom.development.js?61bb:12878) at updateClassComponent (react-dom.development.js?61bb:17426) at beginWork (react-dom.development.js?61bb:19073) at HTMLUnknownElement.callCallback (react-dom.development.js?61bb:3945) at Object.invokeGuardedCallbackDev (react-dom.development.js?61bb:3994) at invokeGuardedCallback (react-dom.development.js?61bb:4056) at beginWork$1 (react-dom.development.js?61bb:23964) at performUnitOfWork (react-dom.development.js?61bb:22776)
index.umd.js?c52c:1 Uncaught TypeError: i.getStorageSync is not a function at c.value (index.umd.js?c52c:1) at callComponentWillMount (react-dom.development.js?61bb:12784) at mountClassInstance (react-dom.development.js?61bb:12878) at updateClassComponent (react-dom.development.js?61bb:17426) at beginWork (react-dom.development.js?61bb:19073) at HTMLUnknownElement.callCallback (react-dom.development.js?61bb:3945) at Object.invokeGuardedCallbackDev (react-dom.development.js?61bb:3994) at invokeGuardedCallback (react-dom.development.js?61bb:4056) at beginWork$1 (react-dom.development.js?61bb:23964) at performUnitOfWork (react-dom.development.js?61bb:22776) react-dom.development.js?61bb:20085 The above error occurred in the component:
环境信息