vue从父组件中获取数组,子组件input循环,绑定v-model的方法

通过绑定key值,如,searchConditionsData是父组件传递过来的数组,

searchConditions: [ {
            name: '名称',
            type: 'text',
            model: 'eq-name',
          },]

子组件绑定自身组件的model,通过condition.key

       <template  v-for="(condition,index) in searchConditionsData">
            <label style="padding: 0 10px;" >{{condition.name}}</label>
            <template v-if=" condition.type== 'text'">
              <Input placeholder="Please enter ..." v-model="condition.key" style="width: 100px"></Input>
            </template>
      </template>

这样子组件的v-model就不受父组件的影响了

猜你喜欢

转载自blog.csdn.net/weixin_40918145/article/details/81088216