Created
March 18, 2022 13:04
-
-
Save cn-2k/742cabd2fb7f1d9942f434a13dd82ea0 to your computer and use it in GitHub Desktop.
V-Model usage inside <script setup> and emit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<input | |
class="input" | |
type="text" | |
:placeholder="props.label" | |
:value="props.modelValue" | |
v-on:input="updateValue($event.target.value)" | |
/> | |
</template> | |
<script setup> | |
import { defineProps, defineEmits } from 'vue' | |
const props = defineProps({ | |
modelValue: String | |
}) | |
const emit = defineEmits(['update:modelValue']) | |
function updateValue(value) { | |
emit('update:modelValue', value) | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment