The array brought by vue.js from the previous page is compared with the current list array. If the key value is the same, add the color. Click to delete the color.

question 1: when initializing the page, you need to determine whether the value of the arr2 array is the same as that of the arr array, and if so, add the corresponding background color
arr2: [

].
{key:"",text:""},
{key:"",text:""},
{key:"",text:""},
{key:"",text:""},

]
Picture

clipboard.png

question 2: when you click a value in the list (such as social insurance and house fund), add the corresponding background color, and click again to delete the background color

the link to the question is here
https://jsfiddle.net/xiyanzi/.

Feb.17,2022

<div id="app">
  <label
      v-for="item in arr" :class="{'active': list.indexOf(item.key) > -1}">
    {{ item.text }}
    <input type="checkbox" v-model="list" :value='item.key'/>
  </label>
</div>

the onClick method is removed, css adds an input {display:none}, and the
initialization code is as follows:

mounted: function() {
    let self = this;
    let arrKeys = self.arr.map((item) => item.key),
        arr2Keys = self.arr2.map((item) => item.key); 
    self.list = arr2Keys.filter((item) => arrKeys.indexOf(item) > -1);
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b39aff-2b9fe.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b39aff-2b9fe.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?