<template>
    <div class="comment-input">
      <textarea v-model="commentText" placeholder="输入评论..." rows="3"></textarea>
      <button @click="submitComment">发布评论</button>
    </div>
  </template>
  
  <script>
  export default {
    data() {
      return {
        commentText: '',  // 存储用户输入的评论
      };
    },
    methods: {
      submitComment() {
        if (this.commentText.trim()) {
          this.$emit('submitComment', this.commentText);  // 向父组件传递评论文本
          this.commentText = '';  // 清空输入框
          this.$emit('updateLikeCount', this.likeCount + 1);
        } else {
          alert("评论不能为空！");
        }
      }
    }
  };
  </script>
  
  <style scoped>
  .comment-input {
    display: flex;
    flex-direction: column;
  }
  
  textarea {
    margin-bottom: 10px;
    padding: 10px;
    font-size: 14px;
    border-radius: 5px;
    border: 1px solid #ddd;
  }
  
  button {
    align-self: flex-end;
    padding: 8px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
  }
  
  button:hover {
    background-color: #0056b3;
  }
  </style>
  