elementui input控件的按键事件的不起作用解决

elementui input控件的按键事件的不起作用解决

Laughing
2020-10-18 / 0 评论 / 1,592 阅读 / 搜一下 / 正在检测是否收录...

使用el-input插件后直接使用keyup等 是不生效的,需要在@keyup等事件后加上native,即@keyup.enter.native='(方法)'

@keydown@keypress都是类似的。

<template>
  <div>
    <el-input @blur="click" @keyup.enter.native="click" v-model="input" placeholder="请输入内容"></el-input>
    <input @keyup.enter="click" v-model="input" placeholder="请输入内容">
  </div>
</template>

<script>
export default {
  name: '事件绑定与监听',
  data () {
    return {
      input: ''
    }
  },
  methods: {
    click: function () {
      debugger
      this.$message({
        message: '警告哦,这是一条警告',
        type: 'warning'
      })
    }
  }
}
</script>

<style scoped>

</style>
0

评论 (0)

取消
  1. 头像
    云缠月
    Windows 7 · Google Chrome

    这样精彩的博客越来越少咯!

    回复