VueJs在select选项中设置自定义属性值

我在用vuejs和laravel ..我想要的是像这样访问名为price的自定义属性。

<select name='unit[]' required @change='change_unit($event)'>
    <option v-for='(unit) in line.units' price='66'  :value='unit.get_unit_id.id'>@{{unit['get_unit_id']['name']}}</option>
</select>

这是vuejs代码

change_unit:function(event)
{
    let get_val = event.target.selectedOptions[0].getAttribute("price");
    console.log("Value from the Attribute: ", get_val)
}

就像这样,一切都很好..但我的问题是,当我想要根据v-for设置价格时,就像这样。

<option v-for='(unit) in line.units' price='unit.price' >

在控制台中,文本'unit.price'而不是实数来自循环中的v-for。那么如何设置基于unit.price的属性价格呢?谢谢..

转载请注明出处:http://www.intsu.net/article/20230504/1207103.html