-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Taro 对接腾讯云对象存储服务COS #17
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Taro 是一套遵循 React 语法规范的 多端开发 解决方案,所以一开始打算使用
cos-js-sdk-v5
,结果发现一直userAgent报错,代理出错,查看源码cos-js-sdk-v5/lib/request.js
,才发现了自己忽略了一个致命错误。cos-js-sdk-v5
使用的是jquery
请求,而小程序是无法使用jquery
的,主要是因为:小程序的页面逻辑是在JsCore
中运行,JsCore
是一个没有窗口对象的环境,所以脚本中不能使用window
对象,也无法在脚本中操作组件,而jquery
会使用到window
对象和document
对象,所以无法使用。进而,使用腾讯云对象储存服务对接小程序的cos-wx-sdk-v5,按照文档直接拖到项目了,运行正确,文件成功上传到腾讯云,但回调
function (err, data)
始终不运行。怎么办,只有一点点排查,在原生中是正常的,那么只能是Taro编译的时候出问题了,所以我们这样解决,在Taro编译时,忽略cos-wx-sdk-v5
文件,我们在config/index.js
配置如下:同时奉上部分代码实现:
The text was updated successfully, but these errors were encountered: