- 发布:2023-01-06 10:17
- 更新:2023-01-09 15:51
- 阅读:213
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win10
HBuilderX类型: 正式
HBuilderX版本号: 3.5.3
手机系统: 全部
手机厂商: 华为
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
App下载地址或H5⽹址: https://www.pgyer.com/MtkW
测试过的手机:
示例代码:
try {
const key = await chooseAndUploadImage(); // 返回的key即上传到COS的图片文件名(不包含域名部分,一般用来提交给后台接口保存到数据库)
const url = await getFileAccessUrl(key); // 返回的url即前面上传到COS的图片的访问地址(包含临时签名)
console.log(url)
this.head_portrait_show = url;
this.userinfo.head_portrait=key;
this.editHeadPortrait()
console.log(this.head_portrait_show)
} catch (error) {
console.log(error);
}
},```
try {
const key = await chooseAndUploadImage(); // 返回的key即上传到COS的图片文件名(不包含域名部分,一般用来提交给后台接口保存到数据库)
const url = await getFileAccessUrl(key); // 返回的url即前面上传到COS的图片的访问地址(包含临时签名)
console.log(url)
this.head_portrait_show = url;
this.userinfo.head_portrait=key;
this.editHeadPortrait()
console.log(this.head_portrait_show)
} catch (error) {
console.log(error);
}
},```
操作步骤:
登录账号后,点击我的,点击头像进入修改个人信息页,点击头像选择图片上传即可复现
登录账号后,点击我的,点击头像进入修改个人信息页,点击头像选择图片上传即可复现
预期结果:
可成功上传图片
可成功上传图片
实际结果:
图片上传不成功且报错
{
"code": "FUNCTIONS_EXECUTE_FAIL",
"errCode": "FUNCTIONS_EXECUTE_FAIL",
"errMsg": "Unexpected token import\n/var/user/node_modules/axios/index.js:1\n(function (exports, require, module, filename, dirname) { import axios from './lib/axios.js';\n ^^^^^^\n\nSyntaxError: Unexpected token import\n at createScript (vm.js:80:10)\n at Object.runInThisContext (vm.js:139:10)\n at Module._compile (module.js:607:28)\n at Object.Module._extensions..js (module.js:654:10)\n at Module.load (module.js:556:32)\n at tryModuleLoad (module.js:499:12)\n at Function.Module._load (module.js:491:3)\n at Module.require (module.js:587:17)\n at require (internal/module.js:11:18)\n at Object.<anonymous> (/var/user/ocr/utils.js:19:15)",
"message": "[tencentcloud-plugin]: Unexpected token import\n/var/user/node_modules/axios/index.js:1\n(function (exports, require, module, filename, dirname) { import axios from './lib/axios.js';\n ^^^^^^\n\nSyntaxError: Unexpected token import\n at createScript (vm.js:80:10)\n at Object.runInThisContext (vm.js:139:10)\n at Module._compile (module.js:607:28)\n at Object.Module._extensions..js (module.js:654:10)\n at Module.load (module.js:556:32)\n at tryModuleLoad (module.js:499:12)\n at Function.Module._load (module.js:491:3)\n at Module.require (module.js:587:17)\n at require (internal/module.js:11:18)\n at Object.<anonymous> (/var/user/ocr/utils.js:19:15)",
"stack": "Error: [tencentcloud-plugin]: Unexpected token import\n/var/user/node_modules/axios/index.js:1\n(function (exports, require, module, filename, dirname) { import axios from './lib/axios.js';\n ^^^^^^\n\nSyntaxError: Unexpected token import\n at createScript (vm.js:80:10)\n at Object.runInThisContext (vm.js:139:10)\n at Module._compile (module.js:607:28)\n at Object.Module._extensions..js (module.js:654:10)\n at Module.load (module.js:556:32)\n at tryModuleLoad (module.js:499:12)\n at Function.Module._load (module.js:491:3)\n at Module.require (module.js:587:17)\n at require (internal/module.js:11:18)\n at Object.<anonymous> (/var/user/ocr/utils.js:19:15)\n at Se._callee8$ (http://localhost:8080/static/js/pagesfb-login-register~pagesfb-login-registerper~pagesfb-user-applycompany~pagesfb-user-applyshop~pa~aa1aa8bb.js:1361:30309)\n at tryCatch (http://localhost:8080/static/js/chunk-vendors.js:21591:40)\n at Generator.invoke [as _invoke] (http://localhost:8080/static/js/chunk-vendors.js:21817:22)\n at Generator.prototype.(anonymous function) [as next] (http://localhost:8080/static/js/chunk-vendors.js:21643:21)\n at asyncGeneratorStep (http://localhost:8080/static/js/chunk-vendors.js:14462:24)\n at _next (http://localhost:8080/static/js/chunk-vendors.js:14484:9)\n at <anonymous>"
}
图片上传不成功且报错
{
"code": "FUNCTIONS_EXECUTE_FAIL",
"errCode": "FUNCTIONS_EXECUTE_FAIL",
"errMsg": "Unexpected token import\n/var/user/node_modules/axios/index.js:1\n(function (exports, require, module, filename, dirname) { import axios from './lib/axios.js';\n ^^^^^^\n\nSyntaxError: Unexpected token import\n at createScript (vm.js:80:10)\n at Object.runInThisContext (vm.js:139:10)\n at Module._compile (module.js:607:28)\n at Object.Module._extensions..js (module.js:654:10)\n at Module.load (module.js:556:32)\n at tryModuleLoad (module.js:499:12)\n at Function.Module._load (module.js:491:3)\n at Module.require (module.js:587:17)\n at require (internal/module.js:11:18)\n at Object.<anonymous> (/var/user/ocr/utils.js:19:15)",
"message": "[tencentcloud-plugin]: Unexpected token import\n/var/user/node_modules/axios/index.js:1\n(function (exports, require, module, filename, dirname) { import axios from './lib/axios.js';\n ^^^^^^\n\nSyntaxError: Unexpected token import\n at createScript (vm.js:80:10)\n at Object.runInThisContext (vm.js:139:10)\n at Module._compile (module.js:607:28)\n at Object.Module._extensions..js (module.js:654:10)\n at Module.load (module.js:556:32)\n at tryModuleLoad (module.js:499:12)\n at Function.Module._load (module.js:491:3)\n at Module.require (module.js:587:17)\n at require (internal/module.js:11:18)\n at Object.<anonymous> (/var/user/ocr/utils.js:19:15)",
"stack": "Error: [tencentcloud-plugin]: Unexpected token import\n/var/user/node_modules/axios/index.js:1\n(function (exports, require, module, filename, dirname) { import axios from './lib/axios.js';\n ^^^^^^\n\nSyntaxError: Unexpected token import\n at createScript (vm.js:80:10)\n at Object.runInThisContext (vm.js:139:10)\n at Module._compile (module.js:607:28)\n at Object.Module._extensions..js (module.js:654:10)\n at Module.load (module.js:556:32)\n at tryModuleLoad (module.js:499:12)\n at Function.Module._load (module.js:491:3)\n at Module.require (module.js:587:17)\n at require (internal/module.js:11:18)\n at Object.<anonymous> (/var/user/ocr/utils.js:19:15)\n at Se._callee8$ (http://localhost:8080/static/js/pagesfb-login-register~pagesfb-login-registerper~pagesfb-user-applycompany~pagesfb-user-applyshop~pa~aa1aa8bb.js:1361:30309)\n at tryCatch (http://localhost:8080/static/js/chunk-vendors.js:21591:40)\n at Generator.invoke [as _invoke] (http://localhost:8080/static/js/chunk-vendors.js:21817:22)\n at Generator.prototype.(anonymous function) [as next] (http://localhost:8080/static/js/chunk-vendors.js:21643:21)\n at asyncGeneratorStep (http://localhost:8080/static/js/chunk-vendors.js:14462:24)\n at _next (http://localhost:8080/static/js/chunk-vendors.js:14484:9)\n at <anonymous>"
}
bug描述:
连接本地云函数可以上传图片,链接云端云函数上传图片报错是什么导致的?云函数已上传。上传到腾讯云存储。使用了腾讯云服务空间。
dcif (作者)
谢谢,解决了大问题
2023-01-10 09:42