Vue Dynamic V-model Within V-for February 24, 2023 Post a Comment I have the following fieldsets containing checkboxes: Copy and you should loop using v-for like : <fieldset v-for="(filters, key,index) in availableFilters"> Copy where the filters represents the value, key represents the key like level and ìndex represents the index such 0, using the key item we could access selected like selected[key] so we could bind the checkbox to that property easily. Full example new Vue({ el: '#app', data() { return { selected: { level: [], subject: [], delivery: [] }, availableFilters: { level: { "UG": 12, "PG": 12, }, subject: { } } } } });Copy <link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script> <div id="app" class="container"> <fieldset v-for="(filters, key,index) in availableFilters"> <label v-for="(count, value) in filters"> <input type="checkbox" :data-filterName="this[filters]" :value="value" v-model="selected[key]" @change="onchange"> {{value}} ({{count}}) </label> </fieldset> <pre>{{selected}}</pre> </div>Copy Share You may like these postsAsp.net 500 Internal Server Error While Calling Webmethod From JavascriptJquery Ajax Call Returning '[object Xmldocument]'Css Next & Previous Clip Path AnimationMediarecorder Ondataavailable Work Successfully Once Post a Comment for "Vue Dynamic V-model Within V-for"
Post a Comment for "Vue Dynamic V-model Within V-for"