elementui 静态删除和新增按钮

在这里插入图片描述

<div>
                            <el-checkbox-group v-model="selectProductAttr[idx].values">
                                <div v-for="(item,index) in selectProductAttr[idx].options" style="display: inline-block"
                                     class="littleMarginLeft">
                                    <el-checkbox :label="item" :key="item"></el-checkbox>
                                    <el-button type="text" class="littleMarginLeft" @click="handleRemoveProductAttrValue(idx,index)">删除
                                    </el-button>
                                </div>
                            </el-checkbox-group>
                            <el-input v-model.trim="addProductAttrValue" style="width: 160px;margin-left: 10px" clearable></el-input>
                            <el-button class="littleMarginLeft" @click="handleAddProductAttrValue(idx)">增加</el-button>
                        </div>
   //手动添加商品属性
            handleAddProductAttrValue(idx){
                if(this.addProductAttrValue==null || this.addProductAttrValue==''){
                    this.$message.warning("属性值不能为空")
                }else if(this.selectProductAttr[idx].options.indexOf(this.addProductAttrValue)!== -1){
                    this.$message.warning("属性值不能重复")
                }else {
                    //手动添加
                    this.selectProductAttr[idx].options.push(this.addProductAttrValue);
                    //清空
                    this.addProductAttrValue='';
                }
            },
            //删除商品属性
            handleRemoveProductAttrValue(idx,index){
                this.selectProductAttr[idx].options.splice(index,1)
            },
可以使用 ElementUI 来构建静态页面。首先需要在 HTML 文件中引入 ElementUI 的 CSS 和 JS 文件,然后按照 ElementUI 的组件文档来使用组件即可。 例如,可以使用以下代码来创建一个包含表格和分页的页面: ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Static Page with ElementUI</title> <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css"> <script src="https://unpkg.com/vue/dist/vue.js"></script> <script src="https://unpkg.com/element-ui/lib/index.js"></script> </head> <body> <div id="app"> <el-table :data="tableData"> <el-table-column prop="name" label="Name"></el-table-column> <el-table-column prop="age" label="Age"></el-table-column> <el-table-column prop="address" label="Address"></el-table-column> </el-table> <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[10, 20, 30, 40]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="1000"> </el-pagination> </div> <script> new Vue({ el: '#app', data: { tableData: [ { name: 'John', age: 18, address: 'New York' }, { name: 'Jane', age: 22, address: 'London' }, { name: 'Bob', age: 30, address: 'Paris' }, { name: 'Alice', age: 25, address: 'Tokyo' } ], currentPage: 1, pageSize: 10 }, methods: { handleSizeChange: function(newSize) { this.pageSize = newSize; }, handleCurrentChange: function(newPage) { this.currentPage = newPage; } } }); </script> </body> </html> ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jq1223

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值