Vue
by ecoblack
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/vuex/3.0.1/vuex.min.js"></script>
<div id="app">
<label>
<input type='checkbox' v-model='theBrothers' value='harpo' />
Harpo
</label>
<label>
<input type='checkbox' v-model='theBrothers' value='groucho' />
Groucho
</label>
<label>
<input type='checkbox' v-model='theBrothers' value='beppo' />
Beppo
</label>
<div>
You have checked: {{ theBrothers }}
</div>
</div>
Vue
const store = new Vuex.Store({
state: {
theBrothers: []
},
})
new Vue({
el: "#app",
store: store,
computed: {
theBrothers: {
set(val){this.$store.state.theBrothers = val},
get(){ return this.$store.state.theBrothers }
}
},
})