“Vue -Form” Code-Antworten

Formular in Vue einreichen

//HTML
<div id="vueRoot">
  <form ref="form">
    <input name="vitalInformation" v-model="store.vital">
    <a href="#" v-on:click="submit">SUBMIT</a>
  </form>
</div>

//JS
vm = new Vue({
  el : "#vueRoot",
  methods : {
    submit : function(){
      this.$refs.form.submit()
    }
  }
});
Amused Aardvark

Wie manipuliert die Mehrfacheingangsoptionsdaten in einer Funktion 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>
Blushing Bison

Vue -Form

<input v-model="message" placeholder="edit me">
<p>Message is: {{ message }}</p>
tooblippe

Ähnliche Antworten wie “Vue -Form”

Fragen ähnlich wie “Vue -Form”

Weitere verwandte Antworten zu “Vue -Form” auf HTML

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen