Forum

MDB VUE Select - ho...
 
Notifications
Clear all

MDB VUE Select - how to read text instead of value (+after initialization)

1 Posty
1 Users
0 Likes
548 Widok
0
Topic starter

ref() troubles

1 Answer
0
Topic starter

If you use ref(), then you have to use selected.value method

<template>
    <MDBSelect v-model:options="options1" v-model:selected="selected1" filter/>
    <span>selected: {{ selectedText }}</span>
</template>


<script>
import {MDBSelect} from "mdb-vue-ui-kit";
import {ref} from "vue";

const options1 = [
    {text: "One", value: 1},
    {text: "Two", value: 2},
    {text: "Three", value: 3},
    {text: "Four", value: 4},
    {text: "Five", value: 5},
    {text: "Six", value: 6},
    {text: "Seven", value: 7},
    {text: "Eight", value: 8}
];
const selected1 = ref(1);

export default {
    components: {
        MDBSelect
    },
    computed:{
      selectedText(){
          return options1[selected1.value-1].text;
      }
    },
    setup() {
        return {
            options1,
            selected1
        };
    }
};
</script>

Odpowiedź

Author Name

Author Email

Your question *

 
Preview 0 Revisions Saved
Share: