iview+vue实现动态添加、删除输入框
<div>
<Row style="margin-top: 10px;" >
<Col span="4" style="text-align: right;margin-top: 15px;"><label >xxx:</label ></Col>
<Col span="17" style="margin-left: 10px;">
<div v-for="(texts,index) in textList">
<div style="align-items:center;display:flex;justify-content:flex-start;margin-top: 10px;">
<Input v-model="texts.name" style="margin-right:10px;" placeholder="10.10.10.1-10.10.10.254" ></Input>
<div>
<Button size="small" style="margin-left:5px;" :disabled="textList.length==1" @click="delText(index)" icon="ios-arrow-up" shape="circle"></Button>
</div>
</div>
</div>
</Col>
<Col span="2" style="margin-top: 14px;">
<Button size="small" style="margin-left:5px;" icon="ios-arrow-down" @click="addText()" shape="circle"></Button>
</Col>
</Row>
</div>
export default {
components: {
},
data() {
return {
textList: [{name: "10.10.10.1-10.10.10.254"}],
texts: ''
}
},
methods: {
addText(){
let length = this.textList.length;
let cope = {
'name': ''
}
this.textList.push(cope);
console.log(this.textList)
},
delText(index){
this.textList.splice(index, 1);
}
}
}