这个问题困扰了我一个多小时,各种测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>

 

内容来源于网络如有侵权请私信删除
你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!

相关课程