uniapp实现---单选题按钮

目录

一、实现思路

二、实现步骤

        ①view部分展示

        ②JavaScript 内容

        ③css中样式展示

三、效果展示


一、实现思路

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

二、实现步骤

        ①view部分展示

                

<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 内容

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

		},

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

        ③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>

三、效果展示

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

      

相关推荐

  1. 按钮选中后取消

    2024-03-11 02:34:03       14 阅读
  2. C脚本实现Wincc按钮启动/停止

    2024-03-11 02:34:03       29 阅读
  3. uniapp使用Uview校验 包括城市选择

    2024-03-11 02:34:03       12 阅读
  4. uniapp----button按钮去除边框

    2024-03-11 02:34:03       45 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-03-11 02:34:03       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-11 02:34:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-11 02:34:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-11 02:34:03       18 阅读

热门阅读

  1. python判断ip是否是本机

    2024-03-11 02:34:03       22 阅读
  2. 3.6作业

    3.6作业

    2024-03-11 02:34:03      26 阅读
  3. uniapp 使用vue-i18n实现传入变量国际化

    2024-03-11 02:34:03       21 阅读
  4. 蓝桥杯2023年-接龙数列(dp)

    2024-03-11 02:34:03       22 阅读
  5. c++ 类内可以定义引用数据成员吗?

    2024-03-11 02:34:03       21 阅读
  6. 代码审查语录

    2024-03-11 02:34:03       16 阅读