Skip to content

Instantly share code, notes, and snippets.

@Tofu-Xx
Last active September 14, 2024 19:17
Show Gist options
  • Save Tofu-Xx/fa475844f9d60c7bb8378c1e5e3ad2d5 to your computer and use it in GitHub Desktop.
Save Tofu-Xx/fa475844f9d60c7bb8378c1e5e3ad2d5 to your computer and use it in GitHub Desktop.
Optimal implementation of v-model's components communicate
<script setup lang="ts">
let modelValue = defineModel("modelValue", { default: () => (0) })
const ins = () => modelValue.value++
</script>
<template>
<button @click="ins">{{ modelValue }}</button>
</template>
<script setup lang="ts">
export let modelValue: number = 0
const ins = () => modelValue++
</script>
<template>
<button @click="ins">{{ modelValue }}</button>
</template>
@Tofu-Xx
Copy link
Author

Tofu-Xx commented Sep 14, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment