[Vuejs]-How to substitute a value in a div in a custom dropdown VUE JS

0👍

Use v-model to bind the value of selected option’s value. Here is an example.

Code below is just example and look more carefully at v-model and @change

<div class="select-item" @change="onChange($event)" v-model="key"
v-for="businessModel in businessModels" 
v-bind:key="businessModel.id"
 v-on:click="businessModelId = businessModel.id; 
addedForm = false;">
           {{ businessModel.name }}
</div>
<script>
var vm = new Vue({
    data: {
        key: ""
    },
    methods: {
        onChange(event) {
            console.log(event.target.value)
        }
    }
}
</script>

After selecting the value because of the v-model the value of key become the value of what u selected then you can bind that value into the box that you want, for example in your situation you can bind it to the "selected".

Leave a comment