inleft
2022-08-26 fa1bd95d533444d7360d1ada127b7a3279a3901f
commit | author | age
bf6fbe 1 // A.vue
L 2
3 <template>
4     <div>
5         <comB></comB>
6         <button @click="changeA">点击改变for</button>
7         <br />tt: {{tt}}
8     </div>
9 </template>
10
11 <script>
12     import comB from './B.vue'
13     export default {
14         name: "A",
15         data() {
16             return {
17                 "tt": "fff"
18             }
19         },
20
21         provide: {
22             for: "demo"
23         },
24         components: {
25             comB
26         },
27         methods: {
28             changeA() {
29                 // 获取到子组件A
30                 this.for = 'this is new value'
31                 this.tt = Math.random()
32             }
33         }
34     }
35 </script>