WriteComment.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <div :style="{'width': width + 'px'}" class="container" style="border-color: white">
  3. <el-input v-model="describe" placeholder="输入你的评论" style="margin-top: 20px" type="textarea"></el-input>
  4. <el-button type="primary" @click="submit" style="margin-top: 20px" round>发表<i class="el-icon-upload el-icon--right"></i></el-button>
  5. </div>
  6. </template>
  7. <script>
  8. import { submitComment } from "../api/comment.js"
  9. export default {
  10. name: "",
  11. data() {
  12. return {
  13. describe: "",
  14. colors: ['#99A9BF', '#F7BA2A', '#FF9900'],
  15. }
  16. },
  17. props: {
  18. width: Number,
  19. postId: Number
  20. },
  21. methods: {
  22. submit() {
  23. if (!this.describe) {
  24. this.$message.warning('请填写评价')
  25. return
  26. }
  27. submitComment({
  28. userId: 0,
  29. content: this.describe,
  30. postId: this.postId
  31. }).then(res => {
  32. if (res.success === 0) {
  33. this.$message.success('发表成功!')
  34. }
  35. else {
  36. this.$message.error(res.message)
  37. }
  38. })
  39. }
  40. }
  41. }
  42. </script>
  43. <style scoped>
  44. </style>