Skip to content
Advertisement

assign value to select in methods in vuejs?

JavaScript
JavaScript

How do I change the <a-select-option>s when I select a radio button?

Advertisement

Answer

You can compute the <a-select>‘s options based on the <a-radio-group>‘s value.

  1. Instead of the change-event handler, use a v-model directive on the <a-radio-group> to store the selected brand, and on the <a-select> to store the selected phone:

    JavaScript
  2. Add a computed property for the options to show based on the selected brand:

    JavaScript
  3. Use a watcher on the phone options to automatically select the first one.

    JavaScript
  4. Render the phone options:

    JavaScript

demo

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement