2020-08-27 17:18:57 +08:00

230 lines
8.8 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="radio-page article">
<h1>Radio 单选</h1>
<h2>概述</h2>
<p>基本组件-单选框主要用于一组可选项单项选择或者单独用于切换到选中状态</p>
<h2>代码示例</h2>
<!-- <Row class="panel">
<Cell class="son-panel" span="12">
<div class="panel-case">
<Radio v-model="checked">
是否同意xxxx
</Radio>
</div>
<div class="panel-header">
<span>基础用法</span>
</div>
<div class="panel-desc">
<p>使用Radio-group实现一组互斥的选项组在组合使用时Radio不再根据checked参数来判断状态而是根据传入的model和value的值自动判断需要将model设置.sync实现数据的双向绑定否则在改变状态时使用者的数据并没有变化每个 Radio 的内容可以自定义如不填写则默认使用 value 的值</p>
</div>
</Cell>
<div class="panel-split" />
<Cell class="son-panel" span="12">
<div class="code">
<markdown1 />
</div>
</Cell>
</Row> -->
<Row class="panel">
<Cell class="son-panel" span="12">
<div class="panel-case">
<Radio-group v-model="value1" @on-change="change">
<Radio value="1">
<Icon type="apple-o" />apple
</Radio>
<Radio value="2">
<Icon type="android" />android
</Radio>
<Radio value="3" disabled>
<Icon type="github" />github
</Radio>
</Radio-group>
</div>
<div class="panel-header">
<span>基础用法</span>
</div>
<div class="panel-desc">
<p>使用Radio-group实现一组互斥的选项组在组合使用时Radio不再根据checked参数来判断状态而是根据传入的model和value的值自动判断需要将model设置.sync实现数据的双向绑定否则在改变状态时使用者的数据并没有变化每个 Radio 的内容可以自定义如不填写则默认使用 value 的值</p>
</div>
</Cell>
<div class="panel-split" />
<Cell class="son-panel" span="12">
<div class="code">
<markdown1 />
</div>
</Cell>
</Row>
<Row class="panel">
<Cell class="son-panel" span="12">
<div class="panel-case">
<Radio-group v-model="value2" vertical @on-change="change">
<Radio value="1">
<Icon type="apple-o" />apple
</Radio>
<Radio value="2">
<Icon type="android" />android
</Radio>
<Radio value="3" disabled>
<Icon type="github" />github
</Radio>
</Radio-group>
</div>
<div class="panel-header">
<span>垂直方向</span>
</div>
<div class="panel-desc">
<p>设置属性 vertical 选项垂直排列</p>
</div>
</Cell>
<div class="panel-split" />
<Cell class="son-panel" span="12">
<div class="code">
<markdown2 />
</div>
</Cell>
</Row>
<Row class="panel">
<Cell class="son-panel" span="12">
<div class="panel-case">
<Radio-group v-model="value3" type="button" @on-change="change">
<Radio value="1">
北京
</Radio>
<Radio value="2">
上海
</Radio>
<Radio value="3" disabled>
深圳
</Radio>
</Radio-group>
</div>
<div class="panel-header">
<span>按钮</span>
</div>
<div class="panel-desc">
<p>设置属性 type=button radio显示为按钮的样子</p>
</div>
</Cell>
<div class="panel-split" />
<Cell class="son-panel" span="12">
<div class="code">
<markdown3 />
</div>
</Cell>
</Row>
<h2>API</h2>
<h3>RadioGroup props</h3>
<section>
<table>
<thead>
<tr>
<th style="text-align:left">属性</th>
<th style="text-align:left">说明</th>
<th style="text-align:left">类型</th>
<th style="text-align:left">默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">value</td>
<td style="text-align:left">选择的值必须设置为.sync</td>
<td style="text-align:left">Number, String</td>
<td style="text-align:left">""</td>
</tr>
<tr>
<td style="text-align:left">vertical</td>
<td style="text-align:left">选项排列方向</td>
<td style="text-align:left">Boolean</td>
<td style="text-align:left">false</td>
</tr>
</tbody>
</table>
</section>
<h3>Input events</h3>
<section>
<table>
<thead>
<tr>
<th style="text-align:left">事件名</th>
<th style="text-align:left">说明</th>
<th style="text-align:left">返回值</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">on-change</td>
<td style="text-align:left">值改变时触发</td>
<td style="text-align:left">event</td>
</tr>
</tbody>
</table>
</section>
<h3>Radio props</h3>
<section>
<table>
<thead>
<tr>
<th style="text-align:left">属性</th>
<th style="text-align:left">说明</th>
<th style="text-align:left">类型</th>
<th style="text-align:left">默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">value</td>
<td style="text-align:left">选项的值必输</td>
<td style="text-align:left">Number, String</td>
<td style="text-align:left">""</td>
</tr>
<tr>
<td style="text-align:left">checked</td>
<td style="text-align:left">是否被选中</td>
<td style="text-align:left">Boolean</td>
<td style="text-align:left">false</td>
</tr>
<tr>
<td style="text-align:left">disabled</td>
<td style="text-align:left">是否禁用</td>
<td style="text-align:left">Boolean</td>
<td style="text-align:left">false</td>
</tr>
</tbody>
</table>
</section>
</div>
</template>
<script type="text/ecmascript-6">
import markdown1 from './md/radio1.md'
import markdown2 from './md/radio2.md'
import markdown3 from './md/radio3.md'
export default {
components: {
markdown1, markdown2, markdown3
},
data: function () {
return {
checked: false,
value1: '1',
value2: '1',
value3: '1'
}
},
ready: function () {
},
methods: {
change(val) {
console.log(val)
}
}
}
</script>