一、效果图
二、代码
//点击事件
rightBtn(sub, index) {
console.log(sub, index)
//uniapp 数组添加不重复元素
if (this.selectList.includes(sub.type)) {
this.selectList = this.selectList.filter((item) => {
return item != sub.type;
});
} else {
this.selectList.push(sub.type);
this.selectList = [...new Set(this.selectList)]; // 数组去重
if (this.selectList.length > 3) {
uni.showToast({
title: "最多选3个",
icon: "none"
});
this.selectList.splice(3, this.selectList.length - 3);
}
}
},