vue中点击按钮,添加一排输入框

编程入门 行业动态 更新时间:2024-10-07 06:49:47

vue中点击按钮,添加一排<a href=https://www.elefans.com/category/jswz/34/1764593.html style=输入框"/>

vue中点击按钮,添加一排输入框

vue界面:
<template><div><el-button @click="add">添加</el-button><el-table :data="data"><el-table-column prop="name" label="名称"><template  slot-scope="scope"><el-input v-model="data[scope.$index].name"></el-input></template>
</el-table-column><el-table-column prop="age" label="年龄"><template  slot-scope="scope"><el-input v-model="data[scope.$index].age"></el-input></template></el-table-column><el-table-column prop="age" label="年龄"><template  slot-scope="scope"><el-button @click="deleteRow(scope.$index)">删除</el-button></template></el-table-column></el-table></div>
</template>js方法:
<script>export  default {data(){return {data:[]}},methods:{add(){this.data.push({});},deleteRow(index){this.data.splice(index,1);}}}
</script>

主要是输入框里面绑定的下标

更多推荐

vue中点击按钮,添加一排输入框

本文发布于:2024-02-14 01:17:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1761422.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:输入框   按钮   vue

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!