vue页面点击按钮增加和删除标签

1、在data()里定义一个空数组:

conditions:[],

2、给数组一个容器,并且遍历数组

<div v-for="item in conditions">
<div>数组中的数据</div>
...
</div>

3、给按钮绑定单击事件

<el-button type="text" @click="newconditions()"><i class="el-icon-circle-plus-outline"></i>新增条件</el-button>

4、在单击事件中利用push方法向数组增加数据(增加标签)

newconditions(){
this.conditions.push(1);
},

5、删除数据

remove(){
this.conditions.pop(1);
}

 

 

posted on 2021-12-28 13:07  萌CAT  阅读(1884)  评论(0编辑  收藏  举报

导航