inleft
2022-08-02 3a5d6662fbeb80426d9708a5d4684bdd5c1f072f
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>