最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue手機端input change時,無法執(zhí)行的問題及解決

 更新時間:2023年05月25日 10:19:20   作者:qq_43103581  
這篇文章主要介紹了vue手機端input change時,無法執(zhí)行的問題及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

vue手機端input change時無法執(zhí)行

vue H5頁面中,有一個搜索功能,回車時執(zhí)行

代碼如下:

<el-input placeholder="請輸入內(nèi)容" prefix-icon="el-icon-search" clearable size="small" v-model="searchVal" @change="search"></el-input>

問題

手機端在搜索時,按如下步驟搜索,會有偶發(fā)性的不執(zhí)行的情況(打字區(qū)域右下角鍵為 “確認”或者“換行”

  • 輸入列表中的某一項,如視頻,點擊右下角的確認
  • 刪除視頻,輸入一些其他文字,再刪除,再輸入,點擊右下角確認

這里寫圖片描述

這里寫圖片描述

當加上form后 確認或換行 就會變?yōu)?前往

<form action="">
    <el-input placeholder="請輸入內(nèi)容" prefix-icon="el-icon-search" clearable size="small" v-model="searchVal" @change="search"></el-input>
</form>

如果該問題依舊存在,在搜索時,將光標移除

<form action="">
    <el-input ref="ipt" placeholder="請輸入內(nèi)容" prefix-icon="el-icon-search" clearable size="small" v-model="searchVal" @change="search"></el-input>
</form>
search () {
    this.$refs.ipt.blur()
    ……
}

vue input[type=‘file’] change事件無法上傳相同文件的問題

== 話不多說,上代碼 ==

html

<input
? ?ref="fileInput"
? ?type="file"
? ?accept="image/*"
? ?style="display: none"
? ?@change="getFile">
<el-button size="mini" type="primary" @click="addLogo">嵌入logo</el-button>
<el-button size="mini" @click="removeLogo">撤銷logo</el-button> ??

js

// 嵌入logo
? ? addLogo() {
? ? ? this.$refs.fileInput.click()
? ? },
// 調(diào)用change方法 ? ?
? ? getFile(event) {
? ? ? const files = event.target.files || null
? ? ? const fileReader = new FileReader() // 內(nèi)置方法new FileReader() ? 讀取文件
? ? ? fileReader.addEventListener('load', () => {
? ? ? ? this.imageUrl = fileReader.result
? ? ? ? this.qrCode.clear()
? ? ? ? this.qrCode2.clear()
? ? ? ? this.options2['logo'] = this.imageUrl
? ? ? ? this.options['logo'] = this.imageUrl
? ? ? ? this.qrCode = new QRCode(this.$refs['QRCode'], this.options)
? ? ? })
? ? ? fileReader.readAsDataURL(files[0])
? ? },
? ?// 撤銷logo
? ? removeLogo() {
? ? ? this.options.logo = ''
? ? ? this.options2.logo = ''
? ? ? this.qrCode.clear()
? ? ? this.qrCode2.clear()
? ? ? this.qrCode = new QRCode(this.$refs['QRCode'], this.options)
? ? }, ? ?

當我點擊嵌入logo,再撤銷logo后,再次嵌入同一張logo時,發(fā)現(xiàn)不起作用,logo沒有嵌入進來,后來明白,是因為我們在嵌入logo地址后,需要將logo地址清空,以便下次嵌入再次寫入logo圖片路徑,這時:

?getFile(event) {
? ? ? const files = event.target.files || null
? ? ? const fileReader = new FileReader() // 內(nèi)置方法new FileReader() ? 讀取文件
? ? ? fileReader.addEventListener('load', () => {
? ? ? ? this.imageUrl = fileReader.result
? ? ? ? this.qrCode.clear()
? ? ? ? this.qrCode2.clear()
? ? ? ? this.options2['logo'] = this.imageUrl
? ? ? ? this.options['logo'] = this.imageUrl
? ? ? ? this.qrCode = new QRCode(this.$refs['QRCode'], this.options)
? ? ? })
? ? ? fileReader.readAsDataURL(files[0])
? ? ? this.$refs.fileInput.value = null ?//我們需要加一個把當前文件路徑清空的方法
? ? },

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。 

相關(guān)文章

最新評論

高尔夫| 宝坻区| 溧阳市| 内丘县| 阳谷县| 贞丰县| 寻甸| 赤城县| 崇仁县| 荆州市| 察雅县| 秦安县| 平和县| 磐安县| 霍林郭勒市| 华容县| 三门峡市| 城市| 大名县| 肃南| 和静县| 洮南市| 岱山县| 海淀区| 镇原县| 巴马| 乌鲁木齐县| 迁安市| 沙坪坝区| 固始县| 上犹县| 宣武区| 柘城县| 贺州市| 苏尼特右旗| 西藏| 遂溪县| 淮滨县| 道真| 淮阳县| 镇巴县|