Giter Club home page Giter Club logo

Comments (6)

yyx990803 avatar yyx990803 commented on May 18, 2024 5

See the form handling section: http://vuex.vuejs.org/en/forms.html

from vuex.

PrimozRome avatar PrimozRome commented on May 18, 2024 3

@airtonix can you post your exact solution with checkboxes/radio buttons please?

from vuex.

airtonix avatar airtonix commented on May 18, 2024

@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?

from vuex.

airtonix avatar airtonix commented on May 18, 2024

nevermind, using this instead:
#38

from vuex.

canmihci avatar canmihci commented on May 18, 2024

really, is there something up with checboxes and radio yet?

from vuex.

yarsky-tgz avatar yarsky-tgz commented on May 18, 2024

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;
    }
  }
});

from vuex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.