Skip to content

Instantly share code, notes, and snippets.

@cn-2k
Created March 18, 2022 13:04
Show Gist options
  • Save cn-2k/742cabd2fb7f1d9942f434a13dd82ea0 to your computer and use it in GitHub Desktop.
Save cn-2k/742cabd2fb7f1d9942f434a13dd82ea0 to your computer and use it in GitHub Desktop.
V-Model usage inside <script setup> and emit
<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