SOURCE

console 命令行工具 X clear

                    
>
console
var Main = {
     data() {
      return {
        dynamicValidateForm: {
          domains: [
            {
              value: '',
              key:'domains',
              title:'域名',
              rules:{
                required: true, message: '域名不能为空1', trigger: 'blur'
              }
          	},
            {
              value: '',
              key:'email',
              title:'邮箱',
              rules:[
      { required: true, message: '请输入邮箱地址', trigger: 'blur' },
      { type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur,change' }
    ]
          	}
          ]
        }
      };
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
  }
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')
<script src="//unpkg.com/vue/dist/vue.js">
</script>
<script src="//unpkg.com/element-ui@1.4.12/lib/index.js">
</script>
<div id="app">
  <el-form :model="dynamicValidateForm" ref="dynamicValidateForm" label-width="100px" class="demo-dynamic">
  <el-form-item
    v-for="(domain, index) in dynamicValidateForm.domains"
    :label="domain.title"
    :key="domain.key"
    :prop="'domains.' + index + '.value'"
    :rules="domain.rules"
  >
    <el-input v-model="domain.value"></el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="submitForm('dynamicValidateForm')">提交</el-button>
    <el-button @click="resetForm('dynamicValidateForm')">重置</el-button>
  </el-form-item>
</el-form>
</div>
@import url("//unpkg.com/element-ui@1.4.12/lib/theme-default/index.css");