歌曲评论
->点击播放时同步显示当前评论
->列表结构
1.点击播放
2.评论获取:axios+歌曲id
3.渲染:v-for
-请求地址:https://autumnfish.cn/comment/hot?type=0
-请求方法:get
-请求参数:id(歌曲id,地址中的type固定为0)
-响应内容:歌曲的热门评论
设置好地址后+&id
我们可以看到里面的数据为以下,而我们要的是为data内hotComments里的content
使用者头像则是user里的avatarUrl,用户名称则是nickname,接着再放入对应的HTML
<!-- 评论 --> <div class="comment_wrapper"> <h5 class='title'>HotComments</h5> <div class='comment_list'> <dl v-for="item in comment"> <dt><img :src="item.user.avatarUrl" alt=""></dt> <dd class="name">{{item.user.nickname}}</dd> <dd class="detail"> {{item.content}} </dd> </dl> </div>
//评论 axios.get("https://autumnfish.cn/comment/hot?type=0&id="+musicId) .then(function(response){ console.log(response) that.comment=response.data.hotComments; },function(err){}) }
就完成歌曲评论了
参考资料:
https://www.bilibili.com/video/BV1HE411e7vY/?p=34&share_source=copy_web&vd_source=85a8c5bb37dc77d30860d2b3537de967