我如何使用vuelidate验证组件中的输入? (文件)

时间:2019-12-11 23:48:45

标签: vue.js vuelidate

Login.vue(父组件)在此组件中,我有“输入”组件,其中包含此输入的输入,我想使用vuelidate对其进行验证

<template>
  <section class="inform w-full">
    <div>
      <form class="w-full" @submit.prevent>
        <div class="form-group">
           <Inputs :type="inputs.type" :placeholder="inputs.placeholder" v-model="inputs.value"/>
        </div>
      </form>
    </div>
  </section>
</template>
<script>
import Inputs from "../../components/form/Inputs";
export default {
  components: {
    Inputs,
  },
  data() {
    return {
      inputs: {
        type: "text",
        placeholder: "Email, Phone, ID",
        value: ""
      },
    };
  },
};
</script>

Inputs.vue(儿童同伴)

<template>
  <input
    :type="type"
    :placeholder="placeholder"
    :value="value"
    @input="$emit('input',$event.target.value)"
  />
</template>
<script>
export default {
  props: ["type", "placeholder", "value"],

};
</script>

0 个答案:

没有答案