-
-
Save mateusavila/3765b30b907a225e1d096584116c1e41 to your computer and use it in GitHub Desktop.
DefineExpose teste
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 lang="ts"> | |
// Exposed.vue | |
const a = 1 | |
const b = ref<number>(2) | |
defineExpose<{ | |
a: number | |
b: globalThis.Ref<number> | |
}>({ | |
a, | |
b | |
}) | |
</script> | |
<template> | |
<div class="w-full">meu componente {{ a }} {{ b }}</div> | |
</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 lang="ts"> | |
import Exposed from '~/components/Exposed.vue' | |
const exposed = ref(null) | |
const b = computed(() => exposed.value?.b) // dá um erro de typescript aqui | |
</script> | |
<template> | |
<div class="w-full"> | |
<main> | |
<Exposed ref="exposed" /> | |
{{ b }} | |
</main> | |
</div> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment