This example is not loading https://ej2.syncfusion.com/vue/documentation/drop-down-list/two-way-binding/#two-way-binding
And I am facing some trouble making two-way-binding work with objects. So I need a working example to see if I'm doing something wrong.
Could anyone help me?
Hi Mauro,
As per your request, we have created the sample with V-model binding. Please find the sample in the attachment:
Find the code example here:
|
<template> <div> <p>V-model value {{value}}</p> <h1>dropdownlist component</h1> <ejs-dropdownlist id="dropdownlist" :dataSource="sportsData" placeholder="select value" :allowFiltering="true" v-model="value" ></ejs-dropdownlist> </div> </template>
<script> import { DropDownListComponent } from "@syncfusion/ej2-vue-dropdowns"; export default { name: "HelloWorld", components: { "ejs-dropdownlist": DropDownListComponent, }, data() { return { value: null, sportsData: ["Badminton", "Cricket", "Football", "Golf", "Tennis"], }; } }; </script>
<!-- Add "scoped" attribute to limit CSS to this component only --> <style> @import "@syncfusion/ej2-base/styles/material.css"; @import "@syncfusion/ej2-inputs/styles/material.css"; @import "@syncfusion/ej2-vue-dropdowns/styles/material.css"; </style> |
Note: If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Regards,
Sureshkumar P
Hi Sureshkumar P, I downloaded the example. I tried to change the initial value to any option. For example,
and the dropdown did not pre-select the value as expected.
Hi Mauro,
We suggest you use the v-model:value instead of v-model when preselecting the value to the component.
Find the modified code example here:
|
<template> <div> <p>V-model value {{value}}</p> <h1>dropdownlist component</h1> <ejs-dropdownlist id="dropdownlist" :dataSource="sportsData" placeholder="select value" :allowFiltering="true" v-model:value="value" ></ejs-dropdownlist> </div> </template> |
Regards,
Sureshkumar P