inleft
2022-08-30 271ca6cb0ee2ff0a789bf74d1821e7891a7043bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// 父组件中
<template>
    <div class="hello_world">
        <div>{{msg}}</div>
        <com-a></com-a>
        <button @click="changeA">点击改变子组件值</button>
    </div>
</template>
 
<script>
    import ComA from './article.vue'
    export default {
        name: 'HelloWorld',
        components: {
            ComA
        },
        data() {
            return {
                msg: 'Welcome'
            }
        },
 
        methods: {
            changeA() {
                // 获取到子组件A
                this.$children[0].messageA = 'this is new value'
            }
        }
    }
</script>