<template>
<view class="content">
<view v-for="item in images" >
<image :src="item"></image>
</view>
<button @click="copy()">上传图片</button>
</view>
</template>
<script>
export default {
data() {
return {
images: [],
}
},
onLoad() {
},
methods: {
copy() {
uni.chooseImage({
success: (res) => {
let tempFilePaths = res.tempFilePaths
if(tempFilePaths.length>0){
for(let i=0;i<tempFilePaths.length;i++){
uni.uploadFile({
url: 'http://vueshop.glbuys.com/api/user/myinfo/formdatahead?token=1ec949a15fb709370f',
filePath: tempFilePaths[i],
name: 'headfile',
success: (uploadFileRes) => {
let data = JSON.parse(uploadFileRes.data)
if (data.code === 200) {
this.images.push('http://vueshop.glbuys.com/userfiles/head/'+data.data.msbox)
}
}
});
}
}
}
})
},
get() {
}
}
}
</script>
<style scoped>
</style>
uniapp 批量上传图片
最新推荐文章于 2024-05-28 13:09:47 发布