Skip to content

Instantly share code, notes, and snippets.

@mateusavila
Created September 25, 2023 18:55
Show Gist options
  • Save mateusavila/3765b30b907a225e1d096584116c1e41 to your computer and use it in GitHub Desktop.
Save mateusavila/3765b30b907a225e1d096584116c1e41 to your computer and use it in GitHub Desktop.
DefineExpose teste
<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>
<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