lijh
2022-01-12 bf6fbec0b5593eb28dc195a58a4208d29b79dfee
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
// 父组件中
<template>
    <div class="section">
        <com-article :articles="articleList" @onEmitIndexEvent="onEmitIndexMethod"></com-article>
        <p>{{currentIndex}}</p>
    </div>
</template>
 
<script>
    import comArticle from './article.vue'
    export default {
        name: 'HelloWorld',
        components: {
            comArticle
        },
        data() {
            return {
                currentIndex: -1,
                articleList: ['红楼梦', '西游记', '三国演义']
            }
        },
        methods: {
            onEmitIndexMethod(idx) {
                this.currentIndex = idx
            }
        }
    }
</script>