uni-app仿抖音评论列表

效果图:
在这里插入图片描述

代码如下:

<template>
	<view>
		<view class="comments">
			<view class="comments-items" v-for="(item, index) in commentContents" :key="index">
				<image :src="item.face" class="comments-face"></image>
				<view class="comments-body">
					<view class="comments-header">{
   {
   item.name}}</view>
					<view class="comments-content">
						{
   {
   item.content}}
					</view>

					<view class="comments-info">
						<text class="grey" style="font-size: 24rpx;">昨天 19:30</text>
						<text class="comments-replay-btn" @click="replay()">回复</text>
					</view>

					<view class="comments-reply">

						<view class="reply">

							<view class="comments-items " v-for="(item2, index2) in item.reply" :key="index2">
								<image :src="item2.face" class="comments-face"></image>
								<view class="comments-body">
									<view class="comments-header">
										{
   {
   item2.name}}
										<template v-if="item2.reply_name">
											<svg t="1600674701420" class="icon reply-more-icon-rotate" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/200
  • 1
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用uniapp实现评论框,你可以按照以下步骤操作: 1. 在uniapp项目中创建一个评论框的组件,可以使用 `<input>` 或 `<textarea>` 元素来实现用户输入评论的功能。 2. 在评论框组件中,监听用户输入的评论内容,可以使用 `v-model` 或 `@input` 来绑定用户输入的值。 3. 添加一个提交按钮或者发送按钮,当用户点击该按钮时,获取用户输入的评论内容并进行处理。你可以使用 `@click` 事件来监听按钮的点击事件,然后调用相应的方法。 4. 在处理评论内容的方法中,你可以进行一些逻辑判断,例如检查评论是否为空或者是否超出了字数限制等。如果有必要,你还可以进行字符串处理,例如去除首尾空格等。 5. 处理完评论内容后,你可以将评论内容发送给后端服务器进行保存或者提交。你可以使用uniapp提供的 `uni.request` 方法或者其他HTTP请求库来发送POST请求。 6. 在成功提交评论后,根据需求更新UI界面,例如显示评论成功的提示消息或者刷新评论列表等。 7. 在组件中,你还可以添加其他相关功能,例如显示剩余字数、添加表情等。 下面是实现评论框的一些示例代码: ```html <template> <div> <textarea v-model="comment" placeholder="请输入评论内容"></textarea> <button @click="submitComment">提交</button> </div> </template> <script> export default { data() { return { comment: '' } }, methods: { submitComment() { if (this.comment.trim() === '') { // 评论不能为空 return; } if (this.comment.length > 200) { // 评论字数不能超过200字 return; } // 发送评论到后端服务器 // 使用uni.request或其他HTTP请求库发送POST请求 } } } </script> ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值