前言

版本更新迭代的时候,需要用到一个动态表单的功能,ElementUI刚好有教程就改改用咯

步骤

代码

<!-- 手机副号动态表单框 -->
        <el-form-item
            v-for="(domains, index) in formData.domains"
            :key="index"
            :prop="'domains.'+ index +'.value'"
            :rules="[
                    { required: true, message: '请输入手机号码', trigger: 'blur' },
                    { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码', trigger: ['blur', 'change'] }
                ]"
        >
            <el-input class="ly-width-280px-im" v-model="domains.value"></el-input>
            <el-button type="danger" icon="el-icon-delete" circle @click.prevent="removeCard(domains)"></el-button>
        </el-form-item>

效果图

02-11 00:24