0
点赞
收藏
分享

微信扫一扫

elementui 静态删除和新增按钮

Jonescy 2022-09-06 阅读 58


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)
},


举报

相关推荐

0 条评论