新特性
常用的 Composition API
- getCurrentInstance
- defineComponent
- defineAsyncComponent
- setup
- ref
- reactive
- watchEffect
- toRef
- toRefs
- provide
- inject
- readOnly
- renderList
- nextTick
script setup Api
- defineProps
- defineEmit
- renderSlots
- useContext
- h
example
defineComponent({
setup(props, { attrs, slots, emit, expose }) {
...
return {}
},
})
<script setup>
const props = defineProps({
title: String,
})
const { slots, attrs } = useContext()
const emit = defineEmit(['chang-name'])
emit('chang-name', 'Tom')
</script>
新的组件
Fragment(片断)
Teleport(瞬移)
Suspense(不确定的)