Answers for "v-model to custom component"

1

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" />
Posted by: Guest on September-05-2021

Browse Popular Code Answers by Language