u
This commit is contained in:
1 parent
97b88528a5
commit
5834738700
10 files changed
+864
-119
No files matched your search
@@ -1,110 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
|
||||
// Group 示例 1: 基本使用 + v-model
|
||||
const selectedValue = ref('B')
|
||||
|
||||
// Group 示例 2: options 数组渲染
|
||||
const options = [
|
||||
{ label: 'XXX', value: 'X' },
|
||||
{ label: '选项 Y', value: 'Y' },
|
||||
{ label: '选项 Z', value: 'Z' },
|
||||
]
|
||||
|
||||
// 单独 Radio 使用
|
||||
const singleChecked = ref(false)
|
||||
|
||||
// Group Disabled
|
||||
const groupDisabled = ref(false)
|
||||
|
||||
function toggleGroupDisabled() {
|
||||
|
||||
groupDisabled.value = !groupDisabled.value
|
||||
console.log(groupDisabled.value);
|
||||
|
||||
}
|
||||
|
||||
function handleChange(val) {
|
||||
console.log('选中值:', val)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="demo-wrapper">
|
||||
<div class="demo-container">
|
||||
<h3>ARadioGroup - 基本使用</h3>
|
||||
<ARadioGroup
|
||||
v-model="selectedValue"
|
||||
default-value="B"
|
||||
:disabled="groupDisabled"
|
||||
class="demo-radio-group"
|
||||
>
|
||||
<ARadio value="A" extra="额外信息">选项 A</ARadio>
|
||||
<ARadio value="B" >选项 B</ARadio>
|
||||
<ARadio value="C">选项 C</ARadio>
|
||||
</ARadioGroup>
|
||||
<p>当前选中: {{ selectedValue }}</p>
|
||||
<button @click="toggleGroupDisabled" class="demo-btn">
|
||||
切换 Group Disabled
|
||||
</button>
|
||||
|
||||
<h3>ARadioGroup - 使用 options 数组渲染</h3>
|
||||
<ARadioGroup
|
||||
v-model="selectedValue"
|
||||
:options="options"
|
||||
@change="handleChange"
|
||||
class="demo-radio-group"
|
||||
/>
|
||||
<p>当前选中: {{ selectedValue }}</p>
|
||||
|
||||
<h3>单独 ARadio 使用</h3>
|
||||
<ARadio v-model="singleChecked" value="X" :allow-uncheck="true">
|
||||
单选 X
|
||||
</ARadio>
|
||||
<p>是否选中: {{ singleChecked }}</p>
|
||||
</div>
|
||||
<div>
|
||||
content
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.demo-wrapper {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
padding: 40px 16px;
|
||||
}
|
||||
<style lang="scss" scoped>
|
||||
|
||||
.demo-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px; /* 各部分垂直间距 */
|
||||
width: 100%;
|
||||
max-width: 600px; /* 页面居中显示 */
|
||||
background-color: #fff;
|
||||
padding: 24px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px rgba(0,0,0,0.08);
|
||||
}
|
||||
|
||||
.demo-radio-group {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
|
||||
.demo-btn {
|
||||
padding: 6px 16px;
|
||||
border: 1px solid #409eff;
|
||||
background-color: #fff;
|
||||
color: #409eff;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: 0.2s;
|
||||
}
|
||||
|
||||
.demo-btn:hover {
|
||||
background-color: #409eff;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user