vue-Vant组件上传图片
生活随笔
收集整理的這篇文章主要介紹了
vue-Vant组件上传图片
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
vue-Vant組件上傳圖片
<van-uploader v-model="fileList" multiple :max-count="1" class = "image" :after-read="afterRead" :max-size="20 * 1024 * 1024"enctype="multipart/form-data"/><br /><van-button type="info" size="normal" @click.prevent="submitimage" native-type="button" class="img">上傳圖片</van-button>@click.prevent
在表單中,除了提交按鈕外,可能還有一些其他的功能性按鈕,如發送驗證碼按鈕。在使用這些按鈕時,要注意將native-type設置為button,否則會觸發表單提交。
限制圖片的大小
if (testimgurl.fileList[0] === undefined) {console.log('未儲存圖片')} else {var size = testimgurl.fileList[0].file.sizeconsole.log(size)if (size > (5 * 1024 * 1024)) {Toast.fail('文件大小不能超過 5M')// console.log('圖片太大,請重新選擇')return 'error'}}總結
以上是生活随笔為你收集整理的vue-Vant组件上传图片的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: UE4-4.26蓝图功能实现:按键控制物
- 下一篇: html5倒计时秒杀怎么做,vue 设