Last active
October 13, 2022 00:49
-
-
Save alquezajanmaverick/fd642a263e31304f79c5c5fcbd1d30d8 to your computer and use it in GitHub Desktop.
Vue 3 SFC v-model
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
<script setup> | |
const props = defineProps({ | |
modelValue: String | |
}) | |
const emit = defineEmits(['update:modelValue']) | |
function updateValue(value) { | |
emit('update:modelValue', value) | |
} | |
</script> | |
<template> | |
<input | |
type="text" | |
:placeholder="props.label" | |
:value="props.modelValue" | |
v-on:input="updateValue($event.target.value)" | |
/> | |
</template> |
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
<script setup> | |
import { ref } from 'vue' | |
import Child from './Child.vue' | |
const name = ref('') | |
</script> | |
<template> | |
<Child v-model="name"/> | |
<p>{{ name }}</p> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment