how do Vue child components interact with their parent components?
case:
<template>
<!-- Details-->
<Details :data="List" />
</template>
<script>
import Details from "./_details";
export default {
components: {
Details
},
data() {
return {
List:[1,2,3,4,5]
}
}
}
</script>
1. The parent component passes a value to the child component, which can be passed through props
. The
subcomponent receives through props.
2. The parent component can get some data about the child component by getting the child component through $refs
.
3. The child component calls the parent component (emit and on are used together) to achieve the transfer of events.
apart from these ways, is there any other way to transfer data and events between parent components and child components? Is there a more convenient way?