Vue2.x案例之商品增删改查的实现 |
您所在的位置:网站首页 › vue表格的增删改查 › Vue2.x案例之商品增删改查的实现 |
td{ border:1px solid #000; } 商品名称 数量 操作 {{product.productName}} {{product.nums}} 编辑 删除 商品名称: 数量: 增加 商品名称: 数量: 修改 取消
$("#div4Update").hide(); //Model var data = { products: [ { id: 1, productName: '袜子', nums: 15}, { id: 2, productName: '羊毛衫', nums: 20}, { id: 3, productName: '雪纺衫', nums: 24}, { id: 4, productName: '高跟鞋', nums: 30} ], product4Add: { id: 0, productName: '', nums: '0'}, product4Update: { id: 0, productName: '', nums: '0'} }; var maxId = 5; for (var i=0;i maxId) maxId= this.products[i].id; } //ViewModel var vue = new Vue({ el: '#app', data: data, methods: { add: function (event) { maxId++; this.product4Add.id = maxId; if(this.product4Add.productName.length==0) this.product4Add.productName = "product-"+this.product4Add.id; //将对象加入到数组 this.products.push(this.product4Add); this.product4Add = { id: 0, productName: '', nums: '0'} }, deleteProduct: function (id) { console.log("id"+id); for (var i=0;i |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |