<div class="test-form" :key="index" v-for="(item, index) in arrs">
<input v-model="item.test_id" @input="changeFunc('test_id', item.test_id ,index)" /> <!-- 如果不加上@input中的方法,那么新增出来input的value会同步一样 -->
</div>
<button @click="addArrHandler"></button>
data(){
arrs : [ ], //数组
arrs_item:{
test_id: ' ',
goals: ' ',
}
},
methods:{
addArrHandler(){
this.arrs.push(this.arrs_item);
},
changeFunc(type, item, index){
if( type === "test_id" ){
this.arrs[index].test_id = item.test_id;
}
},
}