Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Vue select option v-for value not sending any value

I am using select option for displaying multiple item with a certain value. i test it with span so that i could figure if the value what was i expecting but it doesn’t

<div class="mb-3">
     <label for="warehouse" class="form-label">Warehouse</label><br>
     <select name="" id="" class="form-select" v-model="stateWorker.newWarehouse">
            <option v-for="item in state.warehouse" :key="item.warehouse" 
            value="{{item.warehouse}}" >{{item.warehouse}}</option>
     </select>
     <span>test: {{stateWorker.newWarehouse}}</span>
</div>

i was expecting that in span test: warehouse 1. instead i got test: {{item.warehouse}}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Replace value="{{item.warehouse}}" by :value="item.warehouse" :

<div class="mb-3">
<label for="warehouse" class="form-label">Warehouse</label><br />
<select name="" id="" class="form-select" v-model="stateWorker.newWarehouse">
    <option v-for="item in state.warehouse" :key="item.warehouse" :value="item.warehouse">
    {{ item.warehouse }}
    </option>
</select>
<span>test: {{ stateWorker.newWarehouse }}</span>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading