How to pass values of component methods when using VUE components in a list

<el-row>
    <el-col v-for="item in list">
        <el-select @change="select">
            ...
        </el-select>
    </el-col>
</el-row>

//js
select(data){
//data
}
The method in the

vue component will have a default parameter, but if you use it in the list, you want to pass the subscript of item to the method, and if you use @ change= "select (item)", you will override the data parameter. How can I get the values of item and data from select at the same time?

Mar.13,2021

@change="select($event,item)"

to send a subscript, add index, to the v-for to upload the index

refer to the vue documentation


did not see the specific code, I guess
first point: @ change= "select (item)" do you want to pass the current record data through this way
second point: also want to, emit ('change',data in emit); and then pass a data parameter
assumption to this method, I guess right, well, I usually guess wrong, hope this guess is right, the landlord bless me.
as is the case above, in fact, you just want to bring two data, one is the data, that you trigger the environment, and the other is the item when you trigger the environment (in fact, this item can also be used to the environment you trigger), how to get there, you use the item as a data and pass it to the sub-components

<el-row>
    <el-col v-for="item in list">
        <el-select @change="select" :item='item'>
            ...
        </el-select>
    </el-col>
</el-row>

like this, there is one more data in the props of el-select, and you can get this data. Of course, you need to change the props, of the el-select component or you won't get this value, and then you can call emit ('change',data,this.item) through the sub-component, so the two data will pass

.

because I'm using an older version, my current approach is to encapsulate < el-select >

.
Menu