23.music-歌曲评论

歌曲评论
->点击播放时同步显示当前评论
->列表结构
1.点击播放
2.评论获取:axios+歌曲id
3.渲染:v-for

热门评论获取(以下为黑马程序员课程提供)
-请求地址:https://autumnfish.cn/comment/hot?type=0
-请求方法:get
-请求参数:id(歌曲id,地址中的type固定为0)
-响应内容:歌曲的热门评论

设置好地址后+&id
我们可以看到里面的数据为以下,而我们要的是为data内hotComments里的content
http://img2.58codes.com/2024/20163468aHVg2tVvql.png
使用者头像则是user里的avatarUrl,用户名称则是nickname,接着再放入对应的HTML
http://img2.58codes.com/2024/20163468YzF0mg1jfY.png

 <!-- 评论 -->        <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){})        }

就完成歌曲评论了
http://img2.58codes.com/2024/20163468mDPiyYW47n.png

参考资料:
https://www.bilibili.com/video/BV1HE411e7vY/?p=34&share_source=copy_web&vd_source=85a8c5bb37dc77d30860d2b3537de967


关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章