html
添加
行明细
添加
删除
data数据
rowNum: 0,
table: [
{
name: ‘‘,
},
],
方法
// 增加行数
add_row() {
let len = this.order_rowNum;
// 判断输入框的内容
if (this.rowNum === ‘‘ || this.rowNum <= 0 || this.rowNum === null) {
this.$message({
message: ‘请输入正确的行数!‘,
type: ‘error‘
});
} else {
if (len > 0) {
for (let i = 1; i <= len; i++) {
let list = {
name: ‘‘,
}
this.table.push(list);
}
return this.table;
} else {
return this.table;
}
}
},
// 删除按钮
delect(index) {
this.$confirm(‘确认删除表格信息?‘, ‘提示‘, {
showClose: true,
confirmButtonText: ‘确定‘,
cancelButtonText: ‘取消‘,
type: ‘warning‘
})
.then(() => {
this.table.splice(index, 1);
})
.catch(action => {});
},
原文:https://www.cnblogs.com/JaneLifeBlog/p/14034349.html