【发布时间】:2020-09-09 22:00:25
【问题描述】:
我正在使用带有 laravel 的 vuejs .. 我想要的是像这样访问名为 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 设置属性价格 ..
谢谢..
【问题讨论】: