vue3.0结构:
import { PropType } from 'vue' 或者 '@vue/composition-api'
export default defineComponent({
props: {
age: {
type: Number
},
onToggleClick: {
type: Function as PropType<() => void>
}
}
setup(props, {slots, emit, expose, attrs, listeners, root}) {
// slots 插槽使用在下面第6类中介绍
// emit('xxx', xxx)
// expose 有可能是被废弃,当你使用内核为'@vue/composition-api'时是肯定被废弃的
// attrs 跟vue2的 this.$attrs类似
// listeners 跟vue2的 this.$listeners 类似
// root vue实例
// 其他的还有一些,比如 parent, children
}
})
vue3.2