layui/example/docs/zh-CN/components/radio.md

125 lines
2.2 KiB
Markdown
Raw Normal View History

::: anchor
:::
2021-10-26 01:13:23 +08:00
::: title 基础使用
2021-10-24 21:31:42 +08:00
:::
::: demo
<template>
<lay-form>
<lay-radio v-model="selected1" name="action" label="1">写作</lay-radio>
<lay-radio v-model="selected1" name="action" label="2">画画</lay-radio>
<lay-radio v-model="selected1" name="action" label="3">运动</lay-radio>
</lay-form>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const selected1 = ref("1");
return {
2021-10-15 14:27:58 +08:00
selected1
}
}
}
</script>
:::
2021-10-26 01:13:23 +08:00
::: title 禁用状态
2021-10-24 21:31:42 +08:00
:::
::: demo
<template>
<lay-form>
<lay-radio v-model="selected2" name="action" label="1">写作</lay-radio>
<lay-radio v-model="selected2" name="action" label="2">画画</lay-radio>
<lay-radio v-model="selected2" name="action" label="3">运动</lay-radio>
<lay-radio v-model="selected2" name="action" label="4" :disabled="disabled">禁用</lay-radio>
</lay-form>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const disabled = ref(true);
const selected2 = ref("1");
return {
disabled,
selected2
}
}
}
</script>
:::
2021-10-26 01:13:23 +08:00
::: title 事件回调
2021-10-24 21:31:42 +08:00
:::
::: demo
<template>
<lay-form>
<lay-radio v-model="selected3" name="action" label="1" @change="change">写作</lay-radio>
<lay-radio v-model="selected3" name="action" label="2" @change="change">画画</lay-radio>
<lay-radio v-model="selected3" name="action" label="3" @change="change">运动</lay-radio>
</lay-form>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const selected3 = ref("1");
const change = function( current ) {
console.log("当前值:" + current)
}
return {
selected3,
change
}
}
}
</script>
:::
::: title 单选框属性
2021-10-24 21:31:42 +08:00
:::
2021-11-07 15:55:08 +08:00
::: table
| 属性 | 描述 | 默认值 |
| ------- | ------------- | ------ |
| name | 原始属性 name | -- |
| label | 当前值 | -- |
| v-model | 选中值 | -- |
2021-11-07 15:55:08 +08:00
:::
::: title 单选框事件
:::
2021-11-07 15:55:08 +08:00
::: table
| 事件 | 描述 | 参数 |
| ------ | -------- | ---------------- |
| change | 切换事件 | current : 当前值 |
2021-11-07 15:55:08 +08:00
2021-11-07 15:56:24 +08:00
:::
2021-12-16 17:57:59 +08:00
::: comment
:::