-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
V-model directive with computed properties. #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
See the form handling section: http://vuex.vuejs.org/en/forms.html |
@yyx990803 that explains box fields (text/number/date/etc) form fields, but not select,radio or checkbox. <label for="animalDogs">Dags</label>
<input type="radio"
id="animalDogs"
name="animal"
value="dogs"
:checked="animal === 'dogs'"
@change="setAnimal"> <select name="animal"
@change="setAnimal">
<option value="dogs"
:selected="animal === 'dogs'">Dags</option>
<option value="cats"
:selected="animal === 'cats'">Cats</option>
</select> import store from 'app/store';
export default {
computed: {
animal () {
return store.state.animal;
}
},
methods: {
setAnimal: (type) {
store.actions.setAnimal(type);
}
}
} Is this about right? |
nevermind, using this instead: |
@airtonix can you post your exact solution with checkboxes/radio buttons please? |
really, is there something up with checboxes and radio yet? |
You can use https://github.com/yarsky-tgz/vuex-dot for full support of reactive changes on vuex. Checkboxes work too, sure ) Example of simple value changing through incrementing\decrementing: <template>
<button @click.stop="step--">back</button>
<button @click.stop="step++">next</button>
</template>
<script>
import { takeState } from 'vuex-dot';
export default {
computed: {
step: takeState('wizard.step')
.commit('setWizardStep')
.map()
}
}
</script> store/index.js export default new Vuex.Store({
state: {
wizard: {
step: 1
}
},
mutations: {
setWizardStep(state, step) {
state.wizard.step = step;
}
}
}); |
I'm new to the flux pattern. Since components are not supposed to mutate state directly. How would a component designer use v-model directive easily within their app?
The text was updated successfully, but these errors were encountered: