Communication between vue components and components

there are two components in the

index page. There is an isCollapse value in data B A data. How can I get it in component B and do v-model

Aug.23,2021

1.vuex
2. Write a $bus bus communication, do not recommend


recommend vuex is better


A
:
html
<A :yourData="this.yourData"></A>
<script>
    import A from "";// 
    export default {
       components: { A },// 
       data(){
           return {
               yourData:''
           }
       }
    }
</script>

:
<input v-model="this.yourData"/>
<script>
    export default {
       props: ['yourData'],// 
       mounted(){
           console.log(this.yourData) // 
       }
    }
</script>

if the two elements have a common parent component, put the data and data changes to the parent component, bind the data to the child component through props, and all the changes are carried out in the parent component.
in other cases, it is really not possible to use eventBus.


two methods:
1.EventBus
2.Vuex (recommended)

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-1b39acc-2c1a5.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-1b39acc-2c1a5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?