欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

当使用vue的按键修饰符不起效果的时候怎么办?如@keyup.enter = '' ;

程序员文章站 2023-08-22 10:32:19
这个问题困扰了我一个多小时,各种测bug !始终测不出来! 直接上代码(错误示范) 但是问题是:如果我们使用第三方组件这个方法并不奏效了 这时我们应该这么写 ) 注意:这是我们必须在@keyup.enter后面加一个native 来确保这个功能能够得到实现 ......

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