article-comment.vue
766 Bytes
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
36
37
38
39
40
<template>
<Comment ref="comment" :dest-id="articleId"></Comment>
</template>
<script>
export default {
name: 'ArticleComment',
data() {
return {
size: 0,
articleId: 0
};
},
mounted() {
this.articleId = +this.$route.params.articleId;
this.init();
},
activated() {
if (+this.$route.params.articleId !== this.articleId) {
this.articleId = +this.$route.params.articleId;
this.init();
}
},
beforeRouteUpdate(to, from, next) {
if (+this.$route.params.articleId !== +to.params.articleId) {
this.articleId = +to.params.articleId;
this.init();
}
next();
},
methods: {
init() {
this.$nextTick(() => {
this.$refs.comment.init();
});
}
}
};
</script>