當使用vue的按鍵修飾符不起效果的時候怎么辦?如@keyup.enter = '' ;


這個問題困擾了我一個多小時,各種測bug !始終測不出來! 

直接上代碼(錯誤示范)

  <el-form-item prop="password">
        <el-input
           @keyup.enter="check('form')"  //在vue中這個代碼是可行的
          type="password"
          v-model="form.password"
          placeholder="密碼"
          prefix-icon="myicon myicon-key"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" class="login-button" @click="check('form')">登錄</el-button>
      </el-form-item>

 

但是問題是:如果我們使用第三方組件這個方法並不奏效了 這時我們應該這么寫  )

注意這是我們必須在@keyup.enter后面加一個native 來確保這個功能能夠得到實現

  <el-form-item prop="password">
        <el-input
          @keyup.enter.native="check('form')"  
          type="password"
          v-model="form.password"
          placeholder="密碼"
          prefix-icon="myicon myicon-key"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" class="login-button" @click="check('form')">登錄</el-button>
      </el-form-item>

 


免責聲明!

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



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