lijh
2022-01-12 bf6fbec0b5593eb28dc195a58a4208d29b79dfee
commit | author | age
bf6fbe 1 // 父组件中
L 2 <template>
3     <div class="section">
4         <com-article :articles="articleList" @onEmitIndexEvent="onEmitIndexMethod"></com-article>
5         <p>{{currentIndex}}</p>
6     </div>
7 </template>
8
9 <script>
10     import comArticle from './article.vue'
11     export default {
12         name: 'HelloWorld',
13         components: {
14             comArticle
15         },
16         data() {
17             return {
18                 currentIndex: -1,
19                 articleList: ['红楼梦', '西游记', '三国演义']
20             }
21         },
22         methods: {
23             onEmitIndexMethod(idx) {
24                 this.currentIndex = idx
25             }
26         }
27     }
28 </script>