methods:{
addComment(){
console.log(11);
let username = this.username.trim();
let comment = this.comment.trim()
// 先期判断
if(!username){
alert("评论的用户名不能为空")
return;
}
if(!comment){
alert("评论内容不能为空");
return
}
console.log(this.username);
console.log(this.comment);
//传值
this.$emit("addComment",{
name:this.username,
comment:this.comment
}),
// 清空数据
this.username = ''
this.comment = ''
}
}