0
<a-form-item label="Post" :colon="false">
     <a-select
        @change="changeValue"
        placeholder="Select a value"
       >
        <a-select-option
          v-for="(item, index) in value"
          :value="index"
          :key="item.name"
          >{{ item.name }}</a-select-option>
         </a-select>
   </a-form-item>



const value = {
       "post": {
            "title_new": {
                "name": "New",
                "status": 1
            },
            "title_hot": {
                "name": "Hot",
                "status": 1
            },
        },
      "product": {
            "title_new": {
                "name": "samsung",
                "status": 1
            },
            "title_hot": {
                "name": "iphone",
                "status": 1
            },
        }
    }

methods: {
   changeValue(value) {
      console.log(value); //result : post
  }
}

I am displaying value in select box in vuejs.I want when I hit the event @change="changeValue", then i will get one of 2 keys: title_new and title_hot. Like my treatment above. I only get the key is : post and product. Give me your ideas.Thank you

1
  • which ui library are you using? Commented Oct 15, 2021 at 9:18

1 Answer 1

2

You have to just store value of selected radio in a variable (e.g. post, product, ...). Then you can access them by value[radioValue]:

<a-select-option
    v-for="(item, index) in value[radioValue]"
    :value="index"
    :key="item.name"
>
    {{ item.name }}
</a-select-option>
Sign up to request clarification or add additional context in comments.

4 Comments

What if there are 2 keys.. for example post with product..I have corrected the question
You want to show all of them in one select tag?
No. I have checked first, I have 1 radio with post and product..if it selects any I will show the data of that
I have just updated my answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.