我是Vue2新手,我试图在要传递给方法的表单中获得对模型值的引用。我有:
<div v-for="n in maxLength">
<input v-model='price.matrix_prices[n]' /><div @click="fillPrices(?)">set all to this price</div>
{{n}}</div>
matrix_prices是一个具有指定值的散列。假设有人在输入模型中填写了8,我如何获得一个引用,从而使?
为8?
发布于 2017-09-08 13:45:26
在下面的函数中,您可以访问n
吗?
<div v-for="n in maxLength">
<input v-model='price.matrix_prices[n]' />
<div @click="fillPrices(n)">set all to this price
</div>
{{n}}
</div>
如果是,请按如下方式编写该函数:
methods: {
fillPrices(n) {
var data = this.price.matrix_prices[n];
//do something with the data
}
}
https://stackoverflow.com/questions/46122172
复制