亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術文章
文章詳情頁

Vue觸發input選取文件點擊事件操作

瀏覽:78日期:2022-12-12 18:43:27

CSS

.upload-btn-box { margin-bottom: 10px; button { margin-right: 10px; } input[type=file] { display: none; }}

HTML

<div class='upload-btn-box'><Button @click='choiceImg' icon='ios-cloud-upload-outline' type='primary'>點擊上傳</Button> <input ref='filElem' type='file' @change='getFile'></div>

Script

choiceImg(){ this.$refs.filElem.dispatchEvent(new MouseEvent(’click’)) },getFile(){ var that = this; const inputFile = this.$refs.filElem.files[0]; if(inputFile){if(inputFile.type !== ’image/jpeg’ && inputFile.type !== ’image/png’ && inputFile.type !== ’image/gif’){ alert(’不是有效的圖片文件!’); return;}this.imgInfo = Object.assign({}, this.imgInfo, { name: inputFile.name, size: inputFile.size, lastModifiedDate: inputFile.lastModifiedDate.toLocaleString()})const reader = new FileReader();reader.readAsDataURL(inputFile);reader.onload = function (e) { that.imgSrc = this.result;} } else {return; } }

補充知識: vue下打包時幾個文件選擇文件打包一起 并做懶加載

直接上代碼

const DeviceManage = r => require.ensure([], () => r(require(deviceManagePath + ’main/DeviceManage’)), ’g-DeviceManage’);const SingleDeviceSet = r => require.ensure([], () => r(require(deviceManagePath + ’deviceSet/SingleDeviceSet’)), ’g-DeviceManage’);const ModifyNo = r => require.ensure([], () => r(require(deviceManagePath + ’modifyNo/ModifyNo’)), ’g-DeviceManage’);const PricePerTime = r => require.ensure([], () => r(require(deviceManagePath + ’pricePerTime/PricePerTime’)), ’g-DeviceManage’);const SetParams = r => require.ensure([], () => r(require(deviceManagePath + ’setParams/SetParams’)), ’g-DeviceManage’);const ShowDevicePrice = r => require.ensure([], () => r(require(deviceManagePath + ’showDevicePrice/ShowDevicePrice’)), ’g-DeviceManage’);const parameterSetting = r => require.ensure([], () => r(require(deviceManagePath + ’parameterSetting/parameterSetting’)), ’g-DeviceManage’);const SetParams3G = r => require.ensure([], () => r(require(deviceManagePath + ’setParams3G/SetParams3G’)), ’g-Device3Gparams’);

這么寫 所有g-DeviceManage的文件會被打包在一起

以上這篇Vue觸發input選取文件點擊事件操作就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持好吧啦網。

標簽: Vue
相關文章:
主站蜘蛛池模板: 毛片网子 | 激情亚洲网 | 99久99久6久热在线播放 | 日韩专区在线播放 | 成人男女网免费 | jizz免费软件 | 在线视频观看你懂的我的 | 青草视频免费观看在线观看 | 国产成人免费视频 | 国产aⅴ片| 亚洲午夜精品国产电影在线观看 | 99久久国产免费 - 99久久国产免费 | 爱操综合 | 亚洲人成s大片在线播放 | 色综合色综合色综合网址 | 成年视频在线播放 | 国产精品亚洲一区二区三区在线播放 | 日本乱人伦片中文字幕三区 | 中文字幕久久乱码一区二区 | 99久久久国产精品免费牛牛四川 | 久久久久久亚洲精品影院 | 欧美黄色一级视屏 | 在线观看精品国内福利视频 | 国产在线一区二区三区 | 精品亚洲欧美高清不卡高清 | 亚洲婷婷国产精品电影人久久 | 国产黄色大片网站 | www.国产精品 | 色综合久久久久久 | 亚洲精品1区 | 国产美女在线精品亚洲二区 | 免费看欧美一级特黄α大片 | 香蕉视频久久 | 久久久精品2018免费观看 | 国产 欧美 日韩在线 | 黄色不卡视频 | 免费黄色一级大片 | 日韩精品午夜视频一区二区三区 | 亚洲欧美另类国产 | 老头毛片 | 五月四房播|