2

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 ..

0

1 Answer 1

1

You need to bind price attribute. binding attribute

<option v-for='(unit) in line.units' :price='unit.price'>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.