提交 2663efa3 编写于 作者: 雪洛's avatar 雪洛

feat: 增加选择并上传接口

上级 33a71342
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
<view class="uni-btn-v uni-common-mt"> <view class="uni-btn-v uni-common-mt">
<button type="primary" @click="uploadFile">选择文件上传</button> <button type="primary" @click="uploadFile">选择文件上传</button>
<button type="primary" @click="chooseAndUploadFile">一个接口选择文件并上传</button>
</view> </view>
</view> </view>
</view> </view>
...@@ -62,6 +63,26 @@ ...@@ -62,6 +63,26 @@
console.error('chooseImage fail: ', err) console.error('chooseImage fail: ', err)
} }
}) })
},
chooseAndUploadFile() {
uniCloud.chooseAndUploadFile({
type: 'image'
}).then(function (res) {
uni.hideLoading()
console.log(res)
uni.showModal({
content: '上传成功',
showCancel: false
});
})
.catch(function (err : any | null) {
uni.hideLoading()
const error = err as UniCloudError
uni.showModal({
content: '上传失败,' + error.errMsg,
showCancel: false
});
})
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册