ant-design-vue/components/radio/demo/radioGroup-with-name.vue

37 lines
1.1 KiB
Vue
Raw Normal View History

2021-09-01 07:04:46 +00:00
<docs>
---
order: 6
title:
zh-CN: 单选组合 - 配合 name 使用
en-US: Radio.Group with name
---
## zh-CN
可以为 Radio.Group 配置 `name` 参数为组合内的 input 元素赋予相同的 `name` 属性使浏览器把 Radio.Group 下的 Radio 真正看作是一组例如可以通过方向键始终**在同一组内**更改选项
## en-US
Passing the `name` property to all `input[type="radio"]` that are in the same Radio.Group. It is usually used to let the browser see your Radio.Group as a real "group" and keep the default behavior. For example, using left/right keyboard arrow to change your selection that in the same Radio.Group.
</docs>
<template>
2021-09-02 01:26:52 +00:00
<a-radio-group v-model:value="value" name="radioGroup">
2021-09-01 07:04:46 +00:00
<a-radio value="1">A</a-radio>
<a-radio value="2">B</a-radio>
<a-radio value="3">C</a-radio>
<a-radio value="4">D</a-radio>
</a-radio-group>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
export default defineComponent({
setup() {
const value = ref<string>('1');
return {
value,
};
},
});
</script>