inleft
2022-08-26 fa1bd95d533444d7360d1ada127b7a3279a3901f
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>