Reputation: 260
I'm using vuejs with laravel .. what I want is to access custom attribute called price like this ..
<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>
and this is the vuejs code
change_unit:function(event)
{
let get_val = event.target.selectedOptions[0].getAttribute("price");
console.log("Value from the Attribute: ", get_val)
}
like this everything working so good .. but my problem is when I want to set the price based one the v-for like this ..
<option v-for='(unit) in line.units' price='unit.price' >
in console I gat text 'unit.price'
not the real number come from v-for in the loop ..
so how can I set the attribute price based on unit.price..
thanks ..
Upvotes: 2
Views: 1073
Reputation: 1801
You need to bind price
attribute. binding attribute
<option v-for='(unit) in line.units' :price='unit.price'>
Upvotes: 1