How does el-input-number get the subscript

< el-input-number v controls-position= model = "item.buyNum": precision= "0" controls-position= "right" @ change= "handleChange": min= "1" > < / el-input-number >

handleChange (value) {
console.log (value)
}
so I can get the value, but mine is cyclic and I want to get the corresponding subscript at the same time. If I write
< el-input-number v right model = "item.buyNum": precision= "0" controls-position= "right" @ change= "handleChange (index)": min= "1" > < / el-input-number >
handleChange (value,index) {
console.log (value,index)
}
will print

ask how to get index at the same time

Jul.14,2021

in fact, you have already got the index. You can get the bound value according to the index. The parameters you passed have overwritten the callback of the original event.
wrote demo:
clipboard.png

slightly.

https://jsfiddle.net/4w7tnpvo/


you have already got the index, so you can get the corresponding value in the array according to this. For example, the array is list, this.list [index] .buyNum is the value you want.

or try this:
@ change= "handleChange (index)" change to @ change= "handleChange (item.buyNum, index)"

Menu