提交 55855e82 编写于 作者: 雪洛's avatar 雪洛

docs: format code

上级 71bc6ae6
...@@ -107,44 +107,43 @@ onUploadProgress: function(progressEvent) { ...@@ -107,44 +107,43 @@ onUploadProgress: function(progressEvent) {
```javascript ```javascript
//前端代码 //前端代码
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
success(res) { success(res) {
console.log(res); console.log(res);
if (res.tempFilePaths.length > 0) { if (res.tempFilePaths.length > 0) {
let filePath = res.tempFilePaths[0] let filePath = res.tempFilePaths[0]
//进行上传操作 //进行上传操作
// promise方式 // promise方式
const result = await uniCloud.uploadFile({ const result = await uniCloud.uploadFile({
filePath: filePath, filePath: filePath,
cloudPath: 'a.jpg', cloudPath: 'a.jpg',
onUploadProgress: function(progressEvent) { onUploadProgress: function(progressEvent) {
console.log(progressEvent); console.log(progressEvent);
var percentCompleted = Math.round( var percentCompleted = Math.round(
(progressEvent.loaded * 100) / progressEvent.total (progressEvent.loaded * 100) / progressEvent.total
); );
} }
}); });
// callback方式,与promise方式二选一即可 // callback方式,与promise方式二选一即可
uniCloud.uploadFile({ uniCloud.uploadFile({
filePath: filePath, filePath: filePath,
cloudPath: 'a.jpg', cloudPath: 'a.jpg',
onUploadProgress: function(progressEvent) { onUploadProgress: function(progressEvent) {
console.log(progressEvent); console.log(progressEvent);
var percentCompleted = Math.round( var percentCompleted = Math.round(
(progressEvent.loaded * 100) / progressEvent.total (progressEvent.loaded * 100) / progressEvent.total
); );
}, },
success() {}, success() {},
fail() {}, fail() {},
complete() {} complete() {}
}); });
}
}
});
}
}
});
``` ```
**Tips** **Tips**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册