What are the ways in which the Vue child component interacts with the parent component?

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?

Mar.01,2021

that's a lot, but the most commonly used ones are props/emit/callback/$refs and redux-like vux.

other things that are not commonly used are:
local storage, websocket with server, xhr long-term connection, etc.

ps:props down, events up.


t through eventBus

<<script>
import Vue from 'vue'
const bus = new Vue()
export default bus
</script>

similar to calling on,emit by parent and child components, you can also sessionStorage,local Storage


data transfer between vue.js components
if you are interested, you can have a look at it and write out in detail the specific use of the data transferred by various components.


the official website has: use vuex; a simplified version of BUS instance is also given in the official document of vuex; parameters can be passed across several components

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e430d4-449e0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e430d4-449e0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?