码迷,mamicode.com
首页 > 其他好文 > 详细

cv一把梭-elementUI

时间:2020-06-17 10:31:19      阅读:48      评论:0      收藏:0      [点我收藏+]

标签:word   set   code   check   hello   methods   ret   exp   world   

Form

Methods-resetFields

技术图片

<template>
  <div class="home">
    <el-form :model="ruleForm" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="密码" prop="pass">
        <el-input type="password" v-model="ruleForm.pass" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="确认密码" prop="checkPass">
        <el-input type="password" v-model="ruleForm.checkPass" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="年龄" prop="age">
        <el-input v-model.number="ruleForm.age"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary">提交</el-button>
        <el-button @click="resetForm(‘ruleForm‘)">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
// @ is an alias to /src
import HelloWorld from "@/components/HelloWorld.vue";
export default {
  name: "Home",
  components: {
    HelloWorld
  },
  data() {
    return {
      ruleForm: {
        pass: "",
        checkPass: "",
        age: ""
      }
    };
  },
  methods: {
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  }
};
</script>

坑点: 想要使用resetFields, el-form-item标签的prop属性是必须的
技术图片

cv一把梭-elementUI

标签:word   set   code   check   hello   methods   ret   exp   world   

原文地址:https://www.cnblogs.com/chyshy/p/13150757.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!