vue+elementUI實現(xiàn)圖片上傳功能
更新時間:2019年08月20日 10:28:21 作者:Adonis_D_Gogh
這篇文章主要為大家詳細(xì)介紹了vue+elementUI實現(xiàn)圖片上傳功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了vue+elementUI圖片上傳的具體代碼,供大家參考,具體內(nèi)容如下
1、html
<el-form-item label="圖片" prop="logo"> <el-upload name="file" v-if="optype==0" :action="'/upload'" accept=".jpg, .png" list-type="picture-card" :file-list="fileLists" :on-preview="handlePictureCardPreview" :on-success="success" :on-remove="handleRemove"> <i class="el-icon-plus"></i> </el-upload> <!--大圖彈出框--> <el-dialog :visible.sync="imgDialogVisible" size="full" :modal="false" title="查看大圖片"> <img width="100%" :src="dialogImageUrl" alt=""> </el-dialog> </el-form-item>
2、定義
dialogImageUrl: '', imgDialogVisible: false, fileLists: [],
3、在需要使用的方法中給fileLists[]賦值
vm.fileLists = []; if (row.logo != undefined && row.logo != "") { vm.fileLists.push({url:row.logo}); }
4、其他幾個屬性的方法
//刪除圖片 handleRemove(file, fileList) { this.form.logo='' }, //查看大圖 handlePictureCardPreview(file) { this.dialogImageUrl = file.url; this.imgDialogVisible = true; }, //圖片上傳成功 success(response, file, fileList) { this.fileLists = []; this.fileLists = [file] this.form.logo = file.response.result; },
5、圖片上傳的位置和路徑是存在不同的表中。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
vue+springboot實現(xiàn)圖形驗證碼Kaptcha的示例
圖形驗證碼是做網(wǎng)站常用的功能,本文主要介紹了vue+springboot實現(xiàn)圖形驗證碼Kaptcha的示例,具有一定的參考價值,感興趣的可以了解一下2023-11-11Vue2.x中的父組件傳遞數(shù)據(jù)至子組件的方法
這篇文章主要介紹了Vue2.x中的父組件數(shù)據(jù)傳遞至子組件的方法,需要的朋友可以參考下2017-05-05vue el-date-picker 開始日期不能大于結(jié)束日期的實現(xiàn)代碼
這篇文章主要介紹了vue el-date-picker 開始日期不能大于結(jié)束日期的實現(xiàn)代碼,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧2024-01-01Vue3封裝ElImageViewer預(yù)覽圖片的示例代碼
本文主要介紹了Vue3封裝ElImageViewer預(yù)覽圖片的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-07-07