You can use setup syntax sugar directly by adding the setup attribute in the script tag.
After using setup syntax sugar,there is no need to write a setup function; components only need to be introduced without registration; properties and methods do not need to be returned and can be used directly in the template.
defineProps: Child component receives props passed from parent component
defineEmits: The child component calls the method in the parent component
defineExpose: The child component exposes properties, which can be obtained in the parent component
Parent component code
Child component code
{{numb}}
Subcomponent code
{{numb}}
Parent component code
Subcomponent code
子组件中的值{{numb}}
Parent component code