<div class="center">
<div class="title">新增xxx</div>
<div class="fill">
<el-input
class="input"
placeholder="例如xx"
clearable
v-for="(item,i) of CropList" v-model="CropList[i].name" :key="i"
>
</el-input>
<el-button class="gray" type="info" icon="el-icon-plus" @click="addCropListbtn"></el-button>
</div>
</div>
<div class="center">
<div class="title">新增xx周期</div>
<div class="fill fill1">
<div class="fill-center">
<div class="fill-center1" v-for="(item,i) of CropList" :key="i">
<el-button class="gray gray1">{{ CropList[i].name }}</el-button>
<div class="fill-center2">
<el-input
class="input input1 gray1"
placeholder="例如xxx"
clearable
v-for="(item2,index) of item.children" v-model="item2.name"
:key="index"
>
<i slot="suffix" v-if="deleteFalg==true" @click="deletecycle(i,index)"><img :src="item2.img" alt="" srcset=""></i>
</el-input>
<el-button class="white whites" type="info" icon="el-icon-plus"
@click="addCropcycleListbtn(i)"></el-button>
</div>
</div>
</div>
</div>
</div>
<script>
export default {
data(){
return{
CropList: [],//新增xx
}
},
methods:{
deletecycle(i,index){ //删除xxx
this.CropList[i].children.splice(index,1)
},
addCropListbtn(){//新增xxxx
this.CropList.push({
name: "",// 父亲的name
children: [{
name: "",
img:require('../../assets/cha.png')
}]
})
},
addCropcycleListbtn(index){//新增xxx儿子
console.log(index,this.CropList);
this.CropList[index].children.push({
name: "",
img:require('../../assets/cha.png')
})
}
}
}
</script>
新增效果:
删除的效果: