How can the change callback of CheckBox components in elementUI keep the default parameters when custom parameters are used?

when checked, I want to pass the row data item, and insert the uid in the item into the array selectedId according to the value of the value after the CheckBox update.
there is only one default callback parameter in the official document. I want to pass one more parameter on this basis. Is there anything I can do?

clipboard.png

here is my code.

<div id="app">
    <div v-for="item in stylesData">
        <el-checkbox v-model="item.checked" @change="selecteChange(item)"></el-checkbox>
        <img v-bind:src="item.src"/>
        

{{item.text}}

</div> </div> <script> const app = new Vue({ el: "-sharpapp", data: function(){ return { selectedId: [], //UID stylesData: [{ uid: 1, checked: false, src: "xxx.jpg", text: "" },{ uid: 2, checked: false, src: "xxxx.jpg", text: "" },{ uid: 3, checked: false, src: "xxxxx.jpg", text: "" }] } }, methods: { selecteChange: function(item,value){ console.log(item); console.log(value); if(value == true){ app.selectedId.push(item.uid); } } } }); </script>

ask the same question, is there any way to keep the default parameter

A solution has been found.

@change="checked=>(checked,...)"

instance

<el-checkbox :disabled="scope.row.disable" v-model="scope.row.cashStatus"
                       @change="checked=>checkRow(checked, scope.row)"></el-checkbox>
                       
checkRow(checked,row) {
    console.log(`checked:${checked}`)
    console.log(`row:${JSON.stringify(row)}`)
  },

console result:

checked:true
row:{"name":"FB ","disable":false,"cashStatus":true,"netStatus":false}

@change="selecteChange(a,b,c,d...)"

selecteChange(a,b,c,d...){
    //...
}

this form is custom parameter passing, and another is default parameter passing

.
@change="selecteChange"

selecteChange(val,e){
    //...
}

you can use custom parameters. Isn't it enough to pass in an item parameter? Value can be obtained according to item.checked.


here can help you https://blog.csdn.net/qq_37581708/article/details/103088621

Menu