上传单个图片
<el-upload class="dl-avatar-uploader-min square"
:action="uploadUrl"
:show-file-list="false"
:on-success="handleUpImage"
list-type="picture"
>
<img v-if="addform.hole_image" :src="addform.hole_image" class="avatar" title="点击重新上传"/>
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
setup() {
const dataSet = reactive({
uploadUrl:'/api/common/upload',
fileList:[]
})
const methods {
handleUpImage(res){
dataSet.addform.hole_image = res.data.url;
},
}
}
上传多个图片,无限制数量
<el-upload class="dl-avatar-uploader-min square"
:action="uploadUrl"
:on-success="handleUpAvatar"
:on-remove="handleRemove"
:file-list="fileList"
list-type="picture-card"
>
<i class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
setup() {
const dataSet = reactive({
uploadUrl:'/api/common/upload',
fileList:[]
})
const methods {
handleUpAvatar(res){
dataSet.fileList.push(res.data);
},
handleRemove(file,fileList){
dataSet.fileList = fileList;
},
}
}
上传多个图片,有限制数量
<el-upload class="dl-avatar-uploader-min square"
:action="uploadUrl"
:on-success="handleUpAvatar"
:on-remove="handleRemove"
:file-list="fileList"
:limit="9"
list-type="picture-card"
>
<i class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
setup() {
const dataSet = reactive({
uploadUrl:'/api/common/upload',
fileList:[]
})
const methods {
handleUpAvatar(res){
dataSet.fileList.push(res.data);
},
handleRemove(file,fileList){
dataSet.fileList = fileList;
},
}
}