elementUI el-form model 动态生成 ,el-input v-model 动态生成

          <template v-for="(pledgeMovables,pledgeIndex) in protocol.pledgeMovables">
                    <el-form :model="pledgeMovables.model != 'noForm' ? $data[`${pledgeMovables.model}`]:{}" label-width="0">
                        <div v-if="pledgeMovables.subtitle" class="protocol-subtitle">{{pledgeMovables.subtitle}}</div>
                        <div class="protocol-title">{{pledgeMovables.name}}</div>
                        <div class="protocol-msg">
                            <!-- 头部 -->
                            <div class="title">
                                <template v-for="(item,index) in pledgeMovables.title">
                                    <div class="col-line" v-if="item.isLine">
                                        <p :class="[line.include ? 'txtCont-indent noneIndent':'txtLeft',line.font?'fontW':'']" v-for="line in item.lineChildren">
                                            <template v-if="line.include">
                                                <span class="txt-span">
                                                    {{line.label}}
                                                    <template v-for="itm in line.children">
                                                        <span class="txt-span" v-if="itm.type==0">{{itm.label}}</span>
                                                        <el-form-item v-else-if="itm.type==1" :prop="itm.prop" :rules="rule">
                                                            <el-input v-model="$data[`${pledgeMovables.model}`][itm.prop]" @keyup.native="elInputResizeWidth"></el-input>
                                                        </el-form-item>
                                                        <span class="underline" v-else-if="itm.type==2">{{itm.label}}</span>
                                                        <span style="font-weight:bold" v-else-if="itm.type==3">{{itm.label}}</span>
                                                        <span style="font-weight:bold" class="underline" v-else-if="itm.type==4">{{itm.label}}</span>
                                                        <span class="noInput" v-else-if="itm.type==5"></span>
                                                    </template>
                                                </span>
                                            </template>
                                        </p>
                                    </div>
                                </template>
                            </div>
                        </div>
                    </el-form>
                </template>

  

posted @ 2020-01-02 16:49  董七  阅读(4057)  评论(0编辑  收藏  举报