uView Radio 单选框

简介: uView Radio 单选框

单选框用于有一个选择,用户只能选择其中一个的场景。

#平台差异说明

App(vue) App(nvue) H5 小程序

#基本使用

  • 该组件需要搭配radioGroup组件使用,以便用户进行操作时,获得当前单选框组的选中情况
  • 通过v-modelradioGroup组件绑定一个变量,对应的name将会被选中
<template>
  <u-radio-group
    v-model="radiovalue1"
    placement="column"
    @change="groupChange"
  >
    <u-radio
      :customStyle="{marginBottom: '8px'}"
      v-for="(item, index) in radiolist1"
      :key="index"
      :label="item.name"
      :name="item.name"
      @change="radioChange"
    >
    </u-radio>
  </u-radio-group>
</template>
<script>
export default {
  data() {
    return {
          // 基本案列数据
          radiolist1: [{
            name: '苹果',
            disabled: false
          },
            {
              name: '香蕉',
              disabled: false
            },
            {
              name: '橙子',
              disabled: false
            }, {
              name: '榴莲',
              disabled: false
            }
          ],
          // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
          radiovalue1: '苹果',
    };
  },
  methods: {
      groupChange(n) {
        console.log('groupChange', n);
      },
      radioChange(n) {
        console.log('radioChange', n);
      }
  }
};
</script>

copy

#自定义形状

可以通过设置shapesquare或者circle,将单选框设置为方形或者圆形

<u-radio-group v-model="value">
  <u-radio shape="circle" label="月明人倚楼"></u-radio>
</u-radio-group>

copy

#禁用radio

设置disabledtrue,即可禁用某个组件,让用户无法点击

<u-radio-group v-model="value">
  <u-radio :disabled="true" label="明月几时有"></u-radio>
</u-radio-group>

copy

#是否禁止点击提示语选中复选框

设置labelDisabledtrue,即可禁止点击提示语选中复选框

<u-radio-group v-model="value">
  <u-radio :labelDisabled="true" label="明月几时有"></u-radio>
</u-radio-group>

copy

#自定义颜色

此处所指的颜色,为radio选中时的背景颜色,参数为activeColor

<u-radio-group v-model="value">
  <u-radio activeColor="red" label="思悠悠,恨悠悠,恨到归时方始休"></u-radio>
</u-radio-group>

copy

#横向排列形式

可以通过设置placementrow或者column,将复选框设置为横向排列或者竖向排列

<u-radio-group 
    v-model="value"
    placement="row">
  <u-radio activeColor="red" label="思悠悠,恨悠悠,恨到归时方始休"></u-radio>
</u-radio-group>

copy

#横向两端排列形式

可以通过设置iconPlacementleft或者right,将复选框勾选图标的对齐设置为左对齐或者右对齐

<u-radio-group 
    v-model="value"
    iconPlacement="right">
  <u-radio activeColor="red" label="思悠悠,恨悠悠,恨到归时方始休"></u-radio>
</u-radio-group>
相关文章
|
索引
UniApp 组件 u-tabs 详细讲解
UniApp 组件 u-tabs 详细讲解
3122 1
|
SQL 存储 数据库
SQL实践篇(二):为什么微信用SQLite存储聊天记录
SQL实践篇(二):为什么微信用SQLite存储聊天记录
1125 1
|
JavaScript
vue3的7种路由守卫使用大全
vue3的7种路由守卫使用大全
1989 0
|
小程序 API
uniapp小程序选择文件并上传到uniCloud
uniapp小程序选择文件并上传到uniCloud
929 0
|
Web App开发 移动开发 JavaScript
JS - 微信浏览器(H5)语音录音插件(Recorder H5)
JS - 微信浏览器(H5)语音录音插件(Recorder H5)
3388 0
|
网络安全 开发工具 git
Unable to negotiate with xx.xxx.xxxx port 22: no matching host key type found. Their offer: ssh-rsa(解决的两种方式)
Unable to negotiate with xx.xxx.xxxx port 22: no matching host key type found. Their offer: ssh-rsa(解决的两种方式)
6648 0
Unable to negotiate with xx.xxx.xxxx port 22: no matching host key type found. Their offer: ssh-rsa(解决的两种方式)
|
搜索推荐
uview下拉菜单Dropdown整合个性化下拉
uview下拉菜单Dropdown整合个性化下拉
688 5
|
7月前
|
运维 监控 Java
Tomcat配置参数connection-timeout的详细解析和应用讨论
`connection-timeout` 的配置需要根据实际的应用场景、服务器性能、网络环境以及用户行为来决定。因此,开发和运维团队通常需要结合应用特点和监控数据,经过一系列的测试和调优,来确定一个既能保证用户体验,又能维护服务器稳定性和安全性的最优值。
770 0
|
存储 缓存 前端开发
SPA 单页面的优缺点
单页面应用(SPA)优点包括:用户体验流畅、无需刷新页面、减少服务器压力。缺点有:SEO优化困难、初始加载时间长、前端逻辑复杂。
|
Prometheus Cloud Native Java
OpenTelemetry: 经得起考验的工具
OpenTelemetry: 经得起考验的工具
2442 2

热门文章

最新文章