在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ 如何通過js或vue.js使el-select的下拉列表隱藏或失去焦點?

如何通過js或vue.js使el-select的下拉列表隱藏或失去焦點?

升級了最新版本的elementUI使用blur方法就好使了

<el-select :ref="'select'+scope.$index"
                           @keyup.right.native="keyUpRight(2,scope.$index)"
                            v-model="scope.row.unconfirmLineCopy">
keyUpRight(col, row) {
    //最后一行
    if (row === this.selectionList.length - 1) {
      return
    }
    if (col === 1) {
      console.log( row)
      console.log('select' + row)
      console.log(this.$refs['select' + row])
      this.$refs['select' + row].focus()
    } else {
      console.log( row)
      console.log('select' + row)
      console.log(this.$refs['select' + row])
      this.$refs['select' + row].blur()
    }

col等于1時 select可以獲取焦點,col等于2時無法失去焦點

clipboard.png

我通過js讓這個下拉框獲取焦點了,但是沒辦法讓他失去焦點

獲取焦點方法:

this.$refs['select' + row].focus()

失去焦點無用:

this.$refs['select' + row].blur()

index.vue:453 Uncaught TypeError: this.$refs[("select" + row)].blur is not a function

應該怎么辦?

我自己手動點擊其他input這個下拉框能隱藏,但是我通過js讓其他input獲取焦點,這個不會隱藏

這是我獲取到的 <ref=select el-select>

總之我想通過js或者vue將
clipboard.png
這個下拉隱藏

回答
編輯回答
硬扛

不知道這個組件內部是不是有blur事件....?同問

clipboard.png

源碼里面確實有這個方法!不知道是不是你ref沒有獲取到這個組件?

2017年4月8日 14:44
編輯回答
笨尐豬

我用JSFiddle測試了一下。

點擊button,然后點擊展開select,兩秒的setTimeout結束了以后,options確實會被隱藏。
暫時還是不能確定你的問題。
也許你可以補充一下相關代碼,或者用JSfiddle之類的還原一個demo來檢查一下

2017年9月26日 23:21