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

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

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

瀏覽:70日期: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
相關文章:
主站蜘蛛池模板: 国产精品视频免费一区二区三区 | 久久久精品视频免费观看 | 一级特黄录像视频免费 | 亚洲s码 | 中文永久免费看电视网站入口 | 亚洲成人激情片 | 免费a黄色 | 国产精品视频不卡 | 放荡女同老师和女同学生 | 热99re久久国超精品首页 | 婷婷亚洲综合五月天小说在线 | 国产精品免费看久久久 | 国产大片91精品免费观看男同 | 国产亚洲精品久久久久久牛牛 | 窝窝午夜看片成人精品 | 久久鸭综合久久国产 | 国产一区二区三区在线观看精品 | 国产二区精品 | 日本理论在线观看被窝网 | 国产亚洲精品麻豆一区二区 | 最新孕交videosgratis | 久久久久青草 | 国产午夜免费视频 | 国产caoni111在线观看视频 | 天天影视色综合 | 精品久久电影 | 日韩欧美二区 | 日韩系列在线 | 青青热久麻豆精品视频在线观看 | 国产视频色 | 无遮挡男女啪啪成人免费 | 亚洲精品啪啪一区二区三区 | 国产制服丝袜在线观看 | 91视频国产91久久久 | 亚洲成人一区二区 | 国产免费破外女真实出血视频 | 国产91精品黄网在线观看 | 国产草比 | 丁香啪啪天堂激情婷婷 | 免费国产不卡午夜福在线观看 | 国产乱弄视频在线观看 |