vendredi 7 août 2020

Vue.js How to Access Elements of an Object

I have an array of objects:

data: function() {
        return {
            customers:[],
         }
    },

that populates this select box:

         <label>DSO Affiliation:</label>
                <select  class="select-box form-control" name="customer" id="customer" v-model='customer_id' style="-webkit-appearance: none;">
                     <option value="" selected>Choose Customer</option>
                           <option v-for="customer in customers" :value="customer.id">
                                    
                           </option>
                </select>

Once a customer is selected I need to get the customer data from the selected object so that I can populate other form elements such as:

<label>Customer Address:</label>
<input type="text" class="form-control" name="cust_address" v-model='cust_address'>
                       

I have the data in the customers:[ ] array. How do I get the customer data that was was selected in the select box without an additional trip to the server?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire