Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how manipulate the multiple input option data in one function in vue js

<template>
  <select
    :class="$options.name"
    v-model="selected"
    @change="updateValue"
  >
    <option
      disabled
      value=""
      v-text="disabledOption"
    />
    <option
      v-for="option in options"
      :key="option"
      :value="option"
      v-text="option"
    />
  </select>
</template>

<script>
export default {
  name: 'FormSelect',
  model: {
    // By default, `v-model` reacts to the `input`
    // event for updating the value, we change this
    // to `change` for similar behavior as the
    // native `<select>` element.
    event: 'change',
  },
  props: {
    // The disabled option is necessary because
    // otherwise it isn't possible to select the
    // first item on iOS devices. This prop can
    // be used to configure the text for the
    // disabled option.
    disabledOption: {
      type: String,
      default: 'Select something',
    },
    options: {
      type: Array,
      default: () => [],
    },
    value: {
      type: [String, Number],
      default: null,
    },
  },
  data() {
    return {
      selected: this.value,
    };
  },
  methods: {
    updateValue() {
      // Emitting a `change` event with the new
      // value of the `<select>` field, updates
      // all values bound with `v-model`.
      this.$emit('change', this.selected);
    },
  },
};
</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: difference between ajax and node js 
Javascript :: nginx reverse proxy redirect 
Javascript :: find items in array not in another array javascript 
Javascript :: clone array 
Javascript :: import npm dotenv package 
Javascript :: how to create two dimensional array in js 
Javascript :: npm simple zip file creator 
Javascript :: window.location.origin 
Javascript :: express route parameters 
Javascript :: Adding A forEach Function To An HTMLCollection JavaScript 
Javascript :: tobe a number jest 
Javascript :: inheritance in class in js 
Javascript :: javascript goto page 
Javascript :: date in javascript 
Javascript :: array -1 javascript 
Javascript :: database in javascript 
Javascript :: extract text from a string javascript 
Javascript :: event property value in angular 
Javascript :: js push object in array 
Javascript :: animate change background color angular 
Javascript :: reactjs change fill color .svg 
Javascript :: mongoose bulk update 
Javascript :: numero aleatorio javascript 
Javascript :: Find the longest string from a given array 
Javascript :: update to node 15.11 
Javascript :: download file on button click in angular 8 
Javascript :: jquery syntax 
Javascript :: what is a for loop in javascript 
Javascript :: ENOENT, no such file or directory 
Javascript :: javascript functions 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =