<template> <view> <button @click="img" type="primary">button</button> <progress :percent="percent" stroke-width="10" /> </view> </template> <script> var _self; export default { data() { return { percent:0 } }, onLoad(e) { _self=this }, methods: { img(){ //选择照片 uni.chooseImage({ count:1, sizeType:'compressed', success: (res) => { const imgsFile=res.tempFilePaths //上传 const uper=uni.uploadFile({ url: 'https://demo.hcoder.net/index.php?c=uperTest', filePath:imgsFile[0], name:'file', // formData:{ },用于做令牌认证 success:function(res1){ console.log(res1.data) } }) //上传进度更新的方法 uper.onProgressUpdate((e)=>{ console.log(e) _self.percent=e.progress }) } }) } } } </script> <style> </style>