前端开发想省时间就是要找框架呀!找框架!
vant中上传图片组件:https://youzan.github.io/vant/#/zh-CN/uploader
上传图片的组件uploader:
<van-uploader :after-read="onRead" accept="image/*" multiple>
<imgclass="head-img" src="/static/images/addpic.png" ref="goodsImg"/>
</van-uploader>
method中
methods: {
//选择图片后执行
onRead(file) {
console.log(file);
//将原图片显示为选择的图片
this.$refs.goodsImg.src = file.content;
}
}
vant上传的图片是已经base64处理了的,可以直接向后台发了