要避免Element Plus表单在按下回车键时刷新页面,可以使用@keydown.enter.prevent修饰符来阻止默认的回车行为。示例代码如下:

<template>
  <el-form @keydown.enter.prevent>
    <el-form-item label="Input">
      <el-input v-model="inputValue"></el-input>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  data() {
    return {
      inputValue: ''
    }
  }
}
</script>

在上面的示例中,@keydown.enter.prevent修饰符会阻止默认的回车行为,从而避免刷新页面。

elementplus 表单只有一项input 回车时会刷新页面

原文地址: http://www.cveoy.top/t/topic/h72c 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录