🐛 [Bug]: 树插槽中使用 Tiny-radio-group 文本不显示
问题描述
在使用 TinyEngine 的树插槽中, 当我们尝试使用 tiny-radio-group
组件时, 文本显示异常, 但是当我们改变 type
属性为 button
时, 文本显示正常。这种问题在使用 TinyEngine 的树插槽中非常常见, 但是解决方法却不明显。
版本信息
-
版本: latest
-
Vue 版本: 3
-
最小复现链接: 无
-
复现步骤:
在树插槽中,
tiny-radio-group
的type='radio'
显示有问题, 用type='button'
显示正常。附上 demo 代码:<template> <div> <tiny-tree :data="data" default-expand-all> <!-- 默认插槽 --> <template #default="node"> <div style="margin: 0 8px"><tiny-radio-group v-model="value" type='radio' size='mini' :options="options"></tiny-radio-group></div> </template> </tiny-tree> </div> </template> <script setup lang="jsx"> import { ref } from 'vue' import { TinyRadioGroup,TinyTree } from '@opentiny/vue' import { iconPlusSquare } from '@opentiny/vue-icon' const TinyIconPlusSquare = iconPlusSquare() const options = ref([ { label: 'A', text: '很好'}, { label:'B', text: '一般' } ]) const value = ref('A') const data = ref([ { id: '1', label: '数据 1', children: [ { id: '1-1', label: '数据 1-1', children: [{ id: '1-1-1', label: '数据 1-1-1' }] }, { id: '1-2', label: '数据 1-2' } ] }, { id: '2', label: '数据 2', children: [ { id: '2-1', label: '数据 2-1' }, { id: '2-2', label: '数据 2-2' } ] }, { id: '3', label: '数据 3', children: [{ id: '3-1', label: '数据 3-1' }] } ]) </script> <style scoped> </style>
期望结果
- 期望: 文本显示正常
- 实际: 文本显示异常
实际情况
- 实际: 文本显示异常
解决方法
- 解决方法: 使用
type='button'
代替type='radio'
结论
在使用 TinyEngine 的树插槽中, 当我们尝试使用 tiny-radio-group
组件时, 文本显示异常, 但是当我们改变 type
属性为 button
时, 文本显示正常。这种问题在使用 TinyEngine 的树插槽中非常常见, 但是解决方法却不明显。因此, 我们建议使用 type='button'
代替 type='radio'
来解决这个问题。
相关代码
- 相关代码: TinyEngine 树插槽 demo
参考
- TinyEngine 文档
- TinyEngine 树插槽
🐛 [Bug]: 树插槽中使用 tiny-radio-group 文本不显示 =====================================================
问题描述
在使用 TinyEngine 的树插槽中, 当我们尝试使用 tiny-radio-group
组件时, 文本显示异常, 但是当我们改变 type
属性为 button
时, 文本显示正常。这种问题在使用 TinyEngine 的树插槽中非常常见, 但是解决方法却不明显。
版本信息
-
版本: latest
-
Vue 版本: 3
-
最小复现链接: 无
-
复现步骤:
在树插槽中,
tiny-radio-group
的type='radio'
显示有问题, 用type='button'
显示正常。附上 demo 代码:<template> <div> <tiny-tree :data="data" default-expand-all> <!-- 默认插槽 --> <template #default="node"> <div style="margin: 0 8px"><tiny-radio-group v-model="value" type='radio' size='mini' :options="options"></tiny-radio-group></div> </template> </tiny-tree> </div> </template> <script setup lang="jsx"> import { ref } from 'vue' import { TinyRadioGroup,TinyTree } from '@opentiny/vue' import { iconPlusSquare } from '@opentiny/vue-icon' const TinyIconPlusSquare = iconPlusSquare() const options = ref([ { label: 'A', text: '很好'}, { label:'B', text: '一般' } ]) const value = ref('A') const data = ref([ { id: '1', label: '数据 1', children: [ { id: '1-1', label: '数据 1-1', children: [{ id: '1-1-1', label: '数据 1-1-1' }] }, { id: '1-2', label: '数据 1-2' } ] }, { id: '2', label: '数据 2', children: [ { id: '2-1', label: '数据 2-1' }, { id: '2-2', label: '数据 2-2' } ] }, { id: '3', label: '数据 3', children: [{ id: '3-1', label: '数据 3-1' }] } ]) </script> <style scoped> </style>
期望结果
- 期望: 文本显示正常
- 实际: 文本显示异常
实际情况
- 实际: 文本显示异常
解决方法
- 解决方法: 使用
type='button'
代替type='radio'
结论
在使用 TinyEngine 的树插槽中, 当我们尝试使用 tiny-radio-group
组件时, 文本显示异常, 但是当我们改变 type
属性为 button
时, 文本显示正常。这种问题在使用 TinyEngine 的树插槽中非常常见, 但是解决方法却不明显。因此, 我们建议使用 type='button'
代替 type='radio'
来解决这个问题。
相关代码
- 相关代码: TinyEngine 树插槽 demo
参考
Q&A
Q: 为什么 tiny-radio-group 的文本显示异常?
A: 因为 tiny-radio-group 的 type 属性设置为 radio, 这会导致文本显示异常。
Q: 怎么解决这个问题?
A: 可以使用 type='button' 代替 type='radio' 来解决这个问题。
Q: 为什么使用 type='button' 可以解决这个问题?
A: 因为 type='button' 不会导致文本显示异常, 而 type='radio' 会导致文本显示异常。
Q: 有其他解决方法吗?
A: 目前没有其他解决方法, 但是我们建议使用 type='button' 代替 type='radio' 来解决这个问题。
Q: 这个问题在哪些情况下会出现?
A: 这个问题在使用 TinyEngine 的树插槽中非常常见, 但是解决方法却不明显。
Q: 怎么避免这个问题?
A: 可以避免这个问题通过使用 type='button' 代替 type='radio' 来解决这个问题。
Q: 有其他相关问题吗?
A: 有, 但是我们建议使用 type='button' 代替 type='radio' 来解决这个问题。