Reusable Input Field in vue.js

reusable-input-field-in-vue.js

Reusable InputField Component

Create InputField component

<template>
    
        :placeholder="placeholder"
        :type="type"
        :required="required"
        :value="value"
        @input="$emit('update:value', $event.target.value)">
template>

<script>
export default {
  props:{
    type: {
      type: String,
      default: 'text'
    },
    value: {
      type: String,
      required: true
    },
    placeholder: {
      type: String,
      default: ''
    },
    required: {
      type: Boolean,
      default: false
    }
  },
  name: "InputField"
}
script>

Using Reusable InputField

<template>
    
        type="password"
        :value="value"
        :required="true"
        @update:value="(newValue) => (valye = newValue)"/>
template>

<script>
    import InputField from "../../components/resusable/InputField.vue"
    export default {
      components:{
        InputField
      },
      data(){
        return {
          value: ""
        }
    },
}
script>
Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
agile-transformation-isn’t-about-culture-change

Agile Transformation Isn’t About Culture Change

Next Post
what-is-a-feasibility-study?-how-to-conduct-one-for-your-project

What Is a Feasibility Study? How to Conduct One for Your Project

Related Posts