Topic: MDBSelect assign selected value in setup() method.
aceracerff priority asked 2 years ago
Hello,
I have some MDBSelect inside MDBModalBody.
I have a setup() method called from a click event that shows my modal.
I would also like to change the current values of the MDBSelects in that method so that they are set to what I need them to be when the modal shows up.
How can I do this?
If my MDBSelect has:
v-model:options="xyz"
v-model:selected="abc"
And in setup() I have:
const abc = ref("");
const xyz= ref([
{ text: "Win", value: "WIN" },
{ text: "Loss", value: "LOSS" },
{ text: "Draw", value: "DRAW" },
]);
I can't just say, in the setup method,
abc.value = "DRAW"
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
Opened
Specification of the issue
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB Vue
- MDB Version: MDB5 1.0.0
- Device: Windows PC
- Browser: Chrome
- OS: Windows 10
- Provided sample code: No
- Provided link: No
Mikołaj Smoleński staff commented 2 years ago
Selected prop is read-only. To change select value you can use either
setValue
Select method explained here or by addingselected: true
key-value pair to anyxyz
item.Keep coding, Mikołaj from MDB