inleft
2022-08-30 afab3a98a65f7fb4f342251238ab3c329e4242dd
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
31
32
33
34
35
// A.vue
 
<template>
    <div>
        <comB></comB>
        <button @click="changeA">点击改变for</button>
        <br />tt: {{tt}}
    </div>
</template>
 
<script>
    import comB from './B.vue'
    export default {
        name: "A",
        data() {
            return {
                "tt": "fff"
            }
        },
 
        provide: {
            for: "demo"
        },
        components: {
            comB
        },
        methods: {
            changeA() {
                // 获取到子组件A
                this.for = 'this is new value'
                this.tt = Math.random()
            }
        }
    }
</script>