Ready to get started?

Join Adocasts Plus for $8.00/mo, or sign into your account to get access to all of our lessons.

robot mascot smiling

Creating A FormInput Vue Component

In this lesson, we'll create a reusable FormInput Vue Component using our current form field as a starting point.

Published
Sep 13, 24
Duration
7m 9s

Developer, dog lover, and burrito eater. Currently teaching AdonisJS, a fully featured NodeJS framework, and running Adocasts where I post new lessons weekly. Professionally, I work with JavaScript, .Net C#, and SQL Server.

Adocasts

Burlington, KY

Chapters

00:00 - Creating our component file
00:55 - Defining our FormInput props
02:40 - Using our prop values
04:37 - Using our FormInput component
06:00 - Doing some cleanup

Ready to get started?

Join Adocasts Plus for $8.00/mo, or sign into your account to get access to all of our lessons.

Join The Discussion! (2 Comments)

Please sign in or sign up for free to join in on the dicussion.

  1. Commented 14 days ago

    Hello. I believe that with recent versions of Vue, it is possible to handle things more easily.

    The recommended approach to implement two-way binding on a component with v-model is to use the defineModel() macro.

    const model = defineModel()
    
    <Input v-model="model" />
    Copied!

    Prop destructuring is now supported and allows to declare default values.

    const { type = 'text' } = defineProps<{...}>()
    Copied!

    Lastly, there is a shorthand for attribute bindings with same name.

    <Input :type :disabled :required />
    Copied!
    1

    Please sign in or sign up for free to reply

    1. Commented 12 days ago

      Hi gribbl! Thank you for sharing! Yeah, I had missed a number of Vue 3.4's enhancements. I apologize we didn't use any of them in this series. As for 3.5's enhancements, this codebase is still on 3.4 - I don't want to update any packages mid-series until we get to the end where we'll focus on Inertia v2's changes.

      0

      Please sign in or sign up for free to reply