uni-app引入web3在真机运行下兼容性处理方法

uni-app开发跨平台应用程序,项目搭建主要前端框是Uni-app + Vue3 + TS +Vite,项目搭建参考文章Uni-app + Vue3 + TS +Vite 创建项目

Hbuilderx版本是3.6.17

安装web3

yarn add web3

在h5下运行没有问题,但是在真机运行下会出现 

 错误:

09:46:02.159 reportJSException >>>> exception function:createInstanceContext, exception:white screen cause create instanceContext failed,check js stack ->Uncaught TypeError: Cannot use 'in' operator to search for 'URLSearchParams' in undefined

 目前默认安装web3js的版本是1.8.1,解决上述问题方法是,降低版本:

安装[email protected]

yarn add [email protected]

安装完成后,就可以正产使用了:

 

猜你喜欢

转载自blog.csdn.net/sinat_36728518/article/details/128676352
今日推荐