내 의견 테이블 ![enter image description here](https://i.stack.imgur.com/aAgZl.jpg)
내 Comments.vue
<template>
<div class="ui comments innerAllWithoutTop">
<div class="ui inverted active dimmer" v-if="loading">
<div class="ui text loader">Chargement des commentaires...</div>
</div>
<h4 class="ui dividing header">Les commentaires</h4>
<comment :comment="comment" v-for="comment in comments" :key="id"></comment>
<comment-form :id="id" :model="model"></comment-form>
</div>
</template>
<script type="text/babel">
import axios from 'axios'
import Comment from './comments/Comment.vue'
import CommentForm from './comments/Form.vue'
import store from '../store/Store'
export default {
data() {
return {
loading: true,
}
},
computed: {
comments: {
get: function() {
return store.state.comments
},
set: function (comments) {
store.commit('ADD_COMMENTS', comments)
}
}
},
components: { Comment, CommentForm },
props: {
id: Number,
model: String
},
methods: {
getComments() {
axios.get('/comments', {params: {
type: this.model, id: this.id
}}).then((response) => {
this.comments = response.data
}).then(() => {
this.loading = false
});
}
},
mounted() {
this.getComments();
}
}
</script>
내 comment.vue 내가 코멘트를 게시 할 때
<template>
<div class="comment">
<a class="avatar">
<img :src="comment.user.profile.photo">
</a>
<div class="content">
<a class="author">{{ comment.user.username }}</a>
<div class="metadata">
<span class="date">{{ comment.created_at }}</span>
</div>
<div class="text">
{{ comment.content }}
</div>
<div class="actions">
<a class="reply">Répondre</a>
</div>
</div>
<div class="comments" v-if="comment.reply == 0">
<comment :comment="reply" v-for="reply in comment.replies" :key="reply.id"></comment>
<!--<comment-form :model="comment.commentable_type" :id="comment.commentable_id" :reply="comment.id" v-if="comment.reply == 0"></comment-form>-->
</div>
</div>
</template>
<script>
import CommentForm from './Form.vue'
export default {
name: 'comment',
components: { CommentForm },
props: {
comment: Object
}
}
</script>
댓글 작품, 사용자 이름의 작품을하지만 정의되지 않은 코멘트를 얻을 콘솔의 .user
코드 및 테이블 필드를 표시 – urfusion
이것은 vue 코드입니다. 아래를 참조하십시오. –
먼저 답을 없애고 질문을 편집 한 다음 세부 정보를 입력하십시오. 초 테이블에 오류가 발생하는 사용자 이름 입력란이 없습니다. – urfusion