uni-app实现emoj表情包发送【手搓有效】

本文实现了在uniapp项目开发中和小程序,详细的使用emoji表情包,Emoji 表情大全

上代码!!!!
html结构

 

<template>
	<view style="margin-right: 10rpx; margin-left: 20rpx; height: 446rpx;">
		<swiper :current="swiperIndex" style="height: 100%;" @change="swiperChange" :indicator-dots="true">
			<swiper-item v-for="(items, index) in emojData" :key="index">
				<view class="emoj-container">
					<view class="emoj-row">
						<view class="emoj-parent" v-for="(item, i) in items" :key="i" hover-class="checkActive"
							hover-stay-time="100" @click="tuchEmoj(item)">
							<text class="emoj-conn">{{ item }}</text>
						</view>
					</view>
				</view>
			</swiper-item>
		</swiper>
	</view>
</template>

js结构
 

<script>
	export default {
		data() {
			return {
				emojData: [
					['😁', '😀', '😃', '😄', '😁', '😆', '😀', '😃', '😄', '😁', '😆', '😀',
						'😃', '😄', '😁', '😆', '😀', '😃', '😄', '😁', '😆', '😀', '😃', '😄', '😁', '😆', '😀', '😃',
						'😄', '😁', '😆', '😆'
					],
					['😁', '😀', '😃', '😄', '😁', '😆', '😀', '😃', '😄', '😁', '😆', '😀',
						'😃', '😄', '😁', '😆', '😀', '😃', '😄', '😁', '😆', '😀', '😃', '😄', '😁', '😆', '😀', '😃',
						'😄', '😁', '😆', '😆'
					],
					['😁', '😀', '😃', '😄', '😁', '😆', '😀', '😃', '😄', '😁', '😆', '😀',
						'😃', '😄', '😁', '😆', '😀', '😃', '😄', '😁', '😆', '😀', '😃', '😄', '😁', '😆', '😀', '😃',
						'😄', '😁', '😆', '😆'
					],
					['😁', '😀', '😃', '😄', '😁', '😆', '😀', '😃', '😄', '😁', '😆', '😀',
						'😃', '😄', '😁', '😆', '😀', '😃', '😄', '😁', '😆', '😀', '😃', '😄', '😁', '😆', '😀', '😃',
						'😄', '😁', '😆', '😆'
					],
					['😁', '😀', '😃', '😄', '😁', '😆', '😀', '😃', '😄', '😁', '😆', '😀',
						'😃', '😄', '😁', '😆', '😀', '😃', '😄', '😁', '😆', '😀', '😃', '😄', '😁', '😆', '😀', '😃',
						'😄', '😁', '😆', '😆'
					],
				],
				swiperIndex: 0, // 初始 swiper 索引
				selectedEmoji: null, // 用于保存用户选择的表情
			};
		},
		methods: {
			tuchEmoj(item) {
				this.selectedEmoji = item;
				this.$emit('swiperChange', item);
			},
			swiperChange(e) {
				this.swiperIndex = e.detail.current;
			},
		},
	};
</script>

样式
 

<style>
	.emoj-container {
		display: flex;
		flex-direction: column;
	}

	.emoj-row {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
	}

	.emoj-parent {
		margin-left: 8rpx;
		margin-bottom: 5rpx;
		align-items: center;
		margin-top: 8rpx;
		padding-top: 5rpx;
		padding-bottom: 5rpx;
	}

	.checkActive {
		background-color: #e8e8e8 !important;
	}

	.emoj-conn {
		width: 80rpx;
		font-size: 56rpx;
		text-align: center;
	}
</style>

大多数都是用组件化较多的,大家可以通过组件的方式去传递
 

<template>
	<view>
		<emoji-selector @swiperChange="handleEmojiChange"></emoji-selector>
		<view>
			<text>用户选择的表情:</text>
			<text>{{ selectedEmoji }}</text>
		</view>
	</view>
</template>

<script>
	import EmojiSelector from '../components/EmojiSelector.vue';
	export default {
		components: {
			EmojiSelector,
		},
		data() {
			return {
				selectedEmoji: null, // 用于保存用户选择的表情
			};
		},
		methods: {
			handleEmojiChange(emoji) {
				this.selectedEmoji = emoji;
				console.log('用户选择的表情已更新:', emoji);
			},
		},
	};
</script>

<style>

</style>

如果有帮助到你们的 麻烦点个赞谢谢了!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值