这次做了vue页面的图片上传功能,不带裁剪功能的!
首先是html代码,在input框上添加change事件,如下:
<ul class="clearfix">
<li v-if="imgs.length>0" v-for='(item ,index ) in imgs'>
<img :src="item">
</li>
<li style="position:relative" v-if="imgs.length>=6 ? false : true">
<img src="../../assets/img/addimg.png"><input class="upload" @change='add_img' type="file">
</li>
</ul>
我这里做了图片数量的限制,最多6张。