Skip to content
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

uniapp 项目下使用render.js,在 web 上可以上传,但是在安卓下面报错,望解答,谢谢 #669

Open
encorehe opened this issue Aug 20, 2024 · 1 comment

Comments

@encorehe
Copy link

以下为uniapp的项目代码
`


{{vsrc}}-{{ result }}

<view class="content" @click="test">




<script> export default { data(){ return { vsrc:'', result:'111' } }, methods:{ test: function () { var self = this; uni.chooseVideo({ sourceType: ['camera', 'album'], success: function (res) { self.src = res.tempFilePath; self.vsrc = res.tempFilePath; // self.ossUpload(res.tempFile,'aaa.mp4') // qiniu.ossUpload(res.tempFile,'aaa.mp4'); } }); }, getResult(res){ console.log('上传结果',res); this.result = res; } } } </script> <script module="qiniu" lang="renderjs"> import { createDirectUploadTask, createMultipartUploadV2Task, FileData } from 'qiniu-js'; export default { data() { return { title: 'Hello', src:'', progress:0, result:{} } }, onLoad() { }, methods: { sendDataToVue(event, ownerInstance) { console.log(event,ownerInstance); this.$ownerInstance.callMethod('getResult', { // 调用 Vue 组件中的方法 someData: this.result }); }, ossUpload(newValue, oldValue, ownerVm, vm){ let uptoken = 'bA5ywMRj7I2-6x1fPx2C4KQ4Vsz4cLt1Ce63aZ8o:Jrp2b40Znlja18ytBSFevdOY3tE=:eyJzY29wZSI6ImltYWdlcy1maWxlcy10ZXN0IiwiZGVhZGxpbmUiOjE3MjQxNDExMzd9'; const fileData = { type: 'file', data: newValue}; const self = this; const config = { tokenProvider:()=>{ return new Promise((resolve, reject)=>{ resolve(uptoken) }) } } const uploadTask = createMultipartUploadV2Task(fileData, config); // 设置进度回调函数 uploadTask.onProgress((progress, context) => { console.log('progress',JSON.stringify(progress)); self.progress = progress.percent; // 处理进度回调 }); // 设置完成回调函数 uploadTask.onComplete((result, context) => { // 处理完成回调 console.log(result,'result=>') self.result = result; self.sendDataToVue(result); }); // 设置错误回调函数 uploadTask.onError((error, context) => { console.log('error=>',666); // 处理错误回调 console.log( JSON.stringify(error),'error=>'); }); uploadTask.start(); } } } </script> <style> .content { display: flex; flex-direction: column; align-items: center; justify-content: center; } .logo { height: 200rpx; width: 200rpx; margin-top: 200rpx; margin-left: auto; margin-right: auto; margin-bottom: 50rpx; } .text-area { display: flex; justify-content: center; } .title { font-size: 36rpx; color: #8f8f94; } </style>

`
报错:
image

@yinxulai
Copy link
Collaborator

是否给应用赋予了网络权限?可以简单写一个 fetch 测试一下网络连接

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants