# 4.3 单选框(Radio)

用于在多个备选项中选中单个状态。

# 单选框样式

# 应用示例

# dof-radio单选

单选组件,建议以成组的方式出现,使用dof-radio-list

# 实例

# 基础用法

<template>
  <div class="wrapper">
    <dof-minibar
      title="dof-radio"
      background-color="#267AFF"
      text-color="#ffffff"
      :left-button="leftButton"
      @dofMinibarLeftButtonClicked="back"
    ></dof-minibar>
    <scroller class="scroller">
      <title title="dof-radio"></title>
      <category title="使用案例"></category>
      <div class="container">
        <text class="subTitle">当前选中:{{checkedInfo.title}}</text>
        <dof-radio-list :list="list" 
                        @dofRadioItemChecked="itemChecked">
        </dof-radio-list>
      </div>
    </scroller>
  </div>
</template>

<style scoped>
.wrapper {
  background-color: #f2f2f2;
}
.scroller {
  flex: 1;
}
.container{
  padding-bottom: 120px;
}
.subTitle{
  font-size: 28px;
  line-height: 60px;
  margin-left: 32px;
}
</style>

<script>
import { DofRadioList, DofMinibar } from 'dolphin-weex-ui'
import Category from 'src/_mods/catalog'
import Title from 'src/_mods/title.vue'
export default {
  components: { DofMinibar, Category, Title, DofRadioList },
  data: () => ({
    leftButton: '/assets/image/header/back_white@2x.png',
    list: [
      { title: '空调', value: 1},
      { title: '空气净化器', value: 2, checked: true},
      { title: '加湿器', value: 3},
      { title: '电风扇', value: 4}
    ],
    checkedInfo: { title: '空气净化器', value: 2}
  }),
  methods: {
    itemChecked(e) {
      this.checkedInfo = e;
    }

    back() {}
  }
}
</script>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

# Attributes

Prop Type Required Default Description
list Array Y - Radio-list单选组 见注1
title String Y - Radio 显示 label
value [String、Number] Y - Radio 的 value
checked Boolean N false Radio 是否选中
disabled Boolean N false Radio 是否禁用

注1: list

const list=[
        { title: '选项1', value: 1 },
        { title: '选项2', value: 2, checked: true},
        { title: '未选不可修改', value: 5, disabled: true },
        { title: '选项3', value: 3},
        { title: '选项4', value: 4}
      ];
1
2
3
4
5
6
7

# Events

事件名 说明 回调参数
dofRadioItemChecked 选择时触发 e e.value e.title e.oldIndex e.index
Last Updated: 11/1/2022, 4:01:00 PM