uniapp实现---单选题按钮

目录

一、实现思路

二、实现步骤

①view部分展示

[②JavaScript 内容](#②JavaScript 内容)

③css中样式展示

三、效果展示


一、实现思路

使用样式布局控制单选框的位置,这里使用的是原生态uniapp,并没有使用组件。

二、实现步骤

①view部分展示

html 复制代码
<template>
	<view style="padding-bottom: 100px;">
		<f-navbar title="参与评价" navbarType="3"></f-navbar>
		<view style="position: absolute;top: 50px; margin-top: 48rpx;">
			<view style="margin: 48rpx 32rpx;">
				<view class="titlea">您对学校食堂的菜品口味满意吗?</view>
				<view class="radio-group">
					<radio-group @change="radioChange">
						<view class="radio-row">
							<label class="radio-label">
								<radio value="1" class="custom-radio" color="#CCCCCC"/>不满意
							</label>
							<label class="radio-label">
								<radio value="2" class="custom-radio" color="#CCCCCC"/>一般
							</label>
						</view>
						<view class="radio-row">
							<label class="radio-label">
								<radio value="3" class="custom-radio" color="#CCCCCC"/>满意
							</label>
							<label class="radio-label">
								<radio value="4" class="custom-radio" color="#CCCCCC"/>非常满意
							</label>
						</view>
					</radio-group>
				</view>
			</view>

			<view style="margin: 48rpx 32rpx;">
				<view>您对食堂的餐具清洁度满意吗?</view>
				<view class="radio-group">
					<radio-group @change="radioChange">
						<view class="radio-row">
							<label class="radio-label">
								<radio value="1" class="custom-radio" color="#CCCCCC"/>不满意
							</label>
							<label class="radio-label">
								<radio value="2" class="custom-radio" color="#CCCCCC"/>一般
							</label>
						</view>
						<view class="radio-row">
							<label class="radio-label">
								<radio value="3" class="custom-radio" color="#CCCCCC"/>满意
							</label>
							<label class="radio-label">
								<radio value="4" class="custom-radio" color="#CCCCCC"/>非常满意
							</label>
						</view>
					</radio-group>
				</view>
			</view>
		</view>
	</view>

</template>

②JavaScript 内容

javascript 复制代码
<script>
	export default {
		data() {
			return {
				fromdeta: {
					age: '', // 选中的年级
				},
			};

		},

		methods: {
			radioChange(n) {
				console.log('radioChange', n);
			}
		}
	}
</script>

③css中样式展示

css 复制代码
<style scoped lang="scss">
	.radio-group {
		margin: 16rpx;
		display: flex;
		flex-direction: column;

	}

	.radio-row {
		display: flex;
	}

	.radio-label {
		display: flex;
		align-items: center;
		margin-bottom: 24rpx;
		width: 50%;
		font-size: 28rpx;
		color: #1A1A1A;
	}

	/* 调整单选框与文字之间的距离 */
	.custom-radio {
		margin-right: 10rpx;
		transform: scale(0.7)
	}

	.titlea {
		font-size: 32rpx;
		color: #1A1A1A;
		letter-spacing: 2rpx;
	}
</style>

三、效果展示

可以单选,选中的颜色,可以根据自己的需要调节

相关推荐
崎岖Qiu35 分钟前
【设计模式笔记19】:建造者模式
java·笔记·设计模式·建造者模式
syt_101336 分钟前
设计模式之-享元模式
javascript·设计模式·享元模式
dly_blog39 分钟前
ref 与 reactive 的本质区别(第3节)
前端·javascript·vue.js
SUPER52664 小时前
本地开发环境_spring-ai项目启动异常
java·人工智能·spring
moxiaoran57534 小时前
Spring AOP开发的使用场景
java·后端·spring
前端不太难8 小时前
从 Navigation State 反推架构腐化
前端·架构·react
小王师傅668 小时前
【轻松入门SpringBoot】actuator健康检查(上)
java·spring boot·后端
前端程序猿之路8 小时前
Next.js 入门指南 - 从 Vue 角度的理解
前端·vue.js·语言模型·ai编程·入门·next.js·deepseek
大布布将军8 小时前
⚡️ 深入数据之海:SQL 基础与 ORM 的应用
前端·数据库·经验分享·sql·程序人生·面试·改行学it
醒过来摸鱼9 小时前
Java classloader
java·开发语言·python