ShowTopic
file: code/ShowTopic.vue
1: <template>
2: <div class="senph-topic">
3: <AddComment :replyTo="topicUrl" :show="'true'"/>
4: <ul v-if="topic.comments.length > 0">
5: <ShowComment
6: v-for="c in topic.comments"
7: :comment="c"
8: :topicUrl="topicUrl"
9: :key="c.ident"
10: />
11: </ul>
12: <div v-else class="senph-no-comments">
13: No comments yet.
14: </div>
15: </div>
16: </template>
17:
18: <script>
19: import ShowComment from './ShowComment.vue';
20: import AddComment from './AddComment.vue';
21:
22: export default {
23: name: 'ShowTopic',
24: data: function () {
25: return {
26: topic: {
27: comments: []
28: }
29: }
30: },
31: props: [
32: 'topicUrl'
33: ],
34: components: {
35: ShowComment, AddComment
36: },
37: methods: {
38: fetchItems() {
39: if (this.topicUrl) {
40: this.axios.get(this.topicUrl).then((response) => {
41: this.topic = response.data;
42: });
43: }
44: }
45: },
46: created: function(){
47: this.fetchItems();
48: }
49: }
50: </script>
51: