el-popover中使用el-input時,el-input的autofocus失效


 

 

 如圖所示:

  點擊添加分組,出現輸入分組名稱的popover

  需要該popover出現的同時,里面的el-input獲取焦點

  嘗試一:給el-input添加autofocus屬性

  chrome瀏覽器console面板如下反應:

  Autofocus processing was blocked because a document already has a focused element.

  嘗試二:在popover的show event中手動給el-input獲取焦點:

  模板中:

  @show="showPopover"
  
  methods中:
  showPopover() {
    this.$nextTick(() => {
      this.$refs.input.focus()  
    })
  }
  
  親測可行~


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM