article-comment.vue 766 Bytes
<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>