博客
关于我
Element UI 重置表单功能
阅读量:328 次
发布时间:2019-03-04

本文共 508 字,大约阅读时间需要 1 分钟。

在Element UI中实现表单和对话框关闭时的数据重置功能

在实际开发中,当我们使用Element UI组件时,有时会遇到表单数据在关闭对话框时不重置的情况。为了解决这一问题,我们可以通过以下方法实现表单数据的重置。

首先,我们需要为表单组件

设置一个引用名称。例如:

这样我们就可以通过addUserFormRef引用这个表单组件。在对话框组件

中,我们可以设置关闭事件监听函数
addUserDialogClosed。具体实现方式如下:

在对话框关闭的监听函数addUserDialogClosed中,我们只需要调用表单引用addUserFormRefresetFields()方法即可。这样在对话框关闭时,表单的字段会被重置为空。

这种方法简单且高效,适用于需要在对话框关闭时重置表单数据的场景。通过这种方式,我们可以确保用户提交数据后再次打开对话框时表单内容不会保留。

效果如下:

  • 表单引用名称为addUserFormRef
  • 对话框设置关闭事件监听函数addUserDialogClosed
  • 在监听函数中调用resetFields()重置表单内容
  • 这种实现方式直观简洁,非常适合快速开发场景。

    转载地址:http://fptq.baihongyu.com/

    你可能感兴趣的文章
    No module named tensorboard.main在安装tensorboardX的时候遇到的问题
    查看>>
    No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
    查看>>
    No new migrations found. Your system is up-to-date.
    查看>>
    No qualifying bean of type XXX found for dependency XXX.
    查看>>
    No qualifying bean of type ‘com.netflix.discovery.AbstractDiscoveryClientOptionalArgs<?>‘ available
    查看>>
    No resource identifier found for attribute 'srcCompat' in package的解决办法
    查看>>
    no session found for current thread
    查看>>
    no such file or directory AndroidManifest.xml
    查看>>
    No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
    查看>>
    NO.23 ZenTaoPHP目录结构
    查看>>
    no1
    查看>>
    NO32 网络层次及OSI7层模型--TCP三次握手四次断开--子网划分
    查看>>
    NOAA(美国海洋和大气管理局)气象数据获取与POI点数据获取
    查看>>
    NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
    查看>>
    node exporter完整版
    查看>>
    Node JS: < 一> 初识Node JS
    查看>>
    Node JS: < 二> Node JS例子解析
    查看>>
    Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime(72)
    查看>>
    Node 裁切图片的方法
    查看>>
    Node+Express连接mysql实现增删改查
    查看>>