• defineExpose({})
    • 无需导入就可以使用

实例:

<script setup>
import { ref } from 'vue'
const a = 1
const b = ref(2)
defineExpose({
  a,
  b//响应式引用会自动解包
})
</script>

可以获取到暴露的内容为{ "a": 1, "b": 2}