vue-element-from

一,form 属性 方法 事件
1,:model="dialogFormData"  必须参数
 2,status-icon
3,:rules="rules"
4,ref="ruleForm"
5,label-width="100px",
6,class="demo-ruleForm"

二,form-item
1,  label="密码"
2, prop="pass" 验证必须

三,输入组件
1,el-input
      密码    type="password"
      v-model="dialogFormData.pass"
      autocomplete="off"       
     placeholder="请输入内容"

四,验证
1,自定义验证
const validatePass = (rule, value, callback) => {
     if (value === '') {
       callback(new Error('请输入密码'));
     } else {
       if (this.ruleForm2.checkPass !== '') {
      this.$refs.ruleForm2.validateField('checkPass');
          }
      callback();
   }
};

2, 常规验证

rules:{
         pass: [
                    { validator: validatePass, trigger: 'blur' }
                  ],
       
        region: [ { required: true, message: '请选择活动区域', trigger: 'change' } ], },

        date1: [ { type: 'date', required: true, message: '请选择日期', trigger: 'change' } ],  

       name: [ { required: true, message: '请输入活动名称', trigger: 'blur' },
                    { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' } ],

输入框系列
1,select  远程
     
<el-form-item label="客源" prop="CustomerId">
                <el-select
                        v-model="localData.CustomerId"
                        clearable
                        filterable
                        remote
                        default-first-option
                        placeholder="请输入客源编号"
                        :remote-method="remoteMethod"
                        :loading="loading">
                    <el-option
                            v-for="item in remoteSelectOptions"
                            :key="item.Id"
                            :label="item.Name"
                            :value="item.Id">
                        <span style="float: left">{{ item.Name }}</span>
                        <span style="float: left; margin-left: 3px; color: #8492a6; font-size: 13px">{{ item.Code }}</span>
                        <!--<span style="float: right; color: #8492a6; font-size: 13px">{{ item.DictionaryId.Area.Name }}</span>-->
                        <!--<span style="float: right; color: #8492a6; font-size: 13px">【{{ item.Code }}】</span>-->
                        <!--<span style="float: right; color: #8492a6; font-size: 13px">【{{ item.Size }}】</span>-->
                        <!--<span style="float: right; color: #8492a6; font-size: 13px">【{{ item.Trade }}】</span>-->
                        <!--<span style="float: right; color: #8492a6; font-size: 13px">【{{ item.State }}】</span>-->
                        <!--<span style="float: right; color: #8492a6; font-size: 13px">【{{ item.Floor }}/{{item.TotalFloor}}】</span>-->
                    </el-option>
                </el-select>
                <span>{{showCode}}</span>
            </el-form-item>

验证命令:
this. r e f s [ ′ r e s F o r m ′ ] . v a l i d a t e ( ( v a l i e d ) = &gt; ) 等 同 于 t h i s . refs[&#x27;resForm&#x27;].validate((valied)=&gt;{}) 等同于 this. refs[resForm].validate((valied)=>)this.refs.resForm.validate()

动态添加form表单


                    <el-row>
                        <el-col :span="22">
                            <el-form-item
                                    v-if="display==='add'"
                                    v-for="(contact, index) in localData.ContactsId"
                                    :label="'联系人' + index"
                                    :prop="'ContactsId.' + index + '.Mobile'"
                                    :rules="rules.Contacts"
                                    label-width="88px"
                            >
                                <el-col :span="4">
                                    <el-input v-model="contact.Name" placeholder="业主"></el-input>
                                </el-col>
                                <el-col :span="10">
                                    <el-input v-model="contact.Mobile"></el-input>
                                </el-col>
                                <el-col :span="6"></el-col>
                                <el-col :span="4">
                                    <el-button @click.prevent="removeContact(contact)">删除</el-button>
                                </el-col>
                            </el-form-item>
                        </el-col>
                        <el-col :span="2" v-if="display==='add'">
                            <el-button type="primary" round size="small" @click="addContact">添加</el-button>
                        </el-col>

                    </el-row>
                   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值