use v-model in custom component

Hello readers! In this tutorial I have shared the details about “use v-model in custom component”. Okay, let’s move on to the article.

use v-model in custom component

/******************/
/* CUSTOM ELEMENT */
/******************/
<template>
	<!-- Everithing you whant -->
	<input :value="value" @input="$emit('input',$event.target.value)"/>
</template>

<script>
export default 
	name: "CustomElement",
	props: 
    	value: 
			type: String,
			default: ""
		
	

</script>

/******************/
/* PARENT ELEMENT */
/******************/
<CustomElement v-model="someVariable" />

Conclusion

I hope this article helps you to know about “use v-model in custom component”. If you have any doubts regarding this post please let us know via the comment section. Share this post with your friends and family via social networks.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coder Diksha. Here, I post about programming to help developers.

Share on:

Leave a Comment