there are now two arrays. An array A, an array B.
wants to achieve such a function: click the button in array A to add it to array B (implemented here).
if there is this button in array B, it prompts "Don"t repeat it."
I wrote it in VUE. Now the pop-up prompt is stuck here.
Code:
Array An and buttons:
data() {
return {
lablelist: [
{
name: ""
},
{
name: ""
},
{
name: ""
},
{
name: ""
},
{
name: ""
},
],
}
<el-button v-for="(item,key) in lablelist"
type="primary" icon="el-icon-circle-plus-outline" round plain size="small"
native-type="button" @click="lablebtnitem(item,key)">{{item.name}}
</el-button>
Array B and buttons:
waitLoadList: []
<el-button v-for="(item,index) in waitLoadList" type="success"
icon="el-icon-circle-plus-outline" round plain
size="small" native-type="button"
@click="waitlloadbtn(item,index)">{{item.name}}</el-button>
JS:
lablebtnitem(item) {
console.log(item)
let array = this.waitLoadList
if (array.length == 0) {
this.waitLoadList.push({
name: item.name
})
// this.waitLoadList = this.waitLoadList
} else {
array.forEach((data, idx) => {
console.log(data.name)
if (data.name.indexOf(item.name) == -1) {
this.waitLoadList.push({
name: item.name
})
return true
} else {
//
alert("")
return false
// this.waitLoadList = this.waitLoadList
}
})
}
},
now click the first button to add one, the second button to add one, and the third button to add something wrong at the beginning. It"s starting to change a lot.