Home > OS >  VueJs get value input radio in request axios
VueJs get value input radio in request axios

Time:10-03

Hello i have this object

values: {
            false: 'order expected',
            true: 'order cancel'
        }

I'm loop this object inside radio button i wan't to get the value (true or false) in radio button to add in my request axios i'm do that

<div
                    v-for="(index, type) in values"
                    :key="type.id"
                    class="filters__filter-items__type"
                  >
                    <radio-button
                      v-model="order"
                      checked-color="black"
                      class="filters__filter-items__type__radio"
                      :value="index"
                      :name="type"
                      :label="type"
                    />
                  </div>

<button @click="applyFilters"> send </button>
export default {
 data() {
  return {
    order:''
   }
 },
 methods: {
async applyFilters() {
      const app = { $axios: this.$axios };
      const results = await endPoint.searchOrder(
        app,
        this.order
      );
      return results;
    },
  }
}

when i do that my request params is &params=order expected not &params=false I don't understand why please help me thanks

CodePudding user response:

When iterating an object with v-for, the first argument is the value, and the second is the key:

<div v-for="(index, type) in values">
                        
  • Related