VUE监听循环多个input值获取方法

我们在获取后端数据的时候,有时候会在列表中生成很多的input,而我们又想实时监听这些input时要如何处理呢

<tr v-for="(item,index) in bstp" v-if="bstp">
    <td><input type="text" name="" @input="newVal(index,item.value)" v-model="item.value"></td>
</tr>

使用方法在input值发生改变时修改数据

newVal(index,v){
    
    
    let n=parseInt(v);
    if(n<0 || isNaN(n)){
    
    
        n=0;
    }
    this.bstp[index].value=n;
}

猜你喜欢

转载自blog.csdn.net/pgzero/article/details/105673560