vuetify use selected value 1

vuetify use selected value

new Vue({
  el: '#app',
  data: () => ({
    items: [
      {value: '1', bankName: 'Bank1'},
      {value: '2', bankName: 'Bank2'},
    ],
    selectedBank: null
  }),
  methods: {
    directToBank() {
      console.log("Label: ", this.selectedBank.bankName)
      console.log("Value: ", this.selectedBank.value)        
    }
  }
})

Here is what the above code is Doing:
1. We have a list of items that we want to display in the dropdown.
2. We have a selectedBank variable that will hold the selected item.
3. We have a method called directToBank that will be called when the user clicks on the button.
4. We have a v-model directive on the select element that will bind the selected item to the selectedBank variable.
5. We have a v-for directive on the option element that will loop through the items and display them.
6. We have a v-on directive on the button element that will call the directToBank method when the button is clicked.

Similar Posts