Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[checkbox] 设置 options 选项后导致禁用失败的问题 #1693

Closed
Leviathangk opened this issue Dec 31, 2024 · 1 comment · Fixed by #1713
Closed

[checkbox] 设置 options 选项后导致禁用失败的问题 #1693

Leviathangk opened this issue Dec 31, 2024 · 1 comment · Fixed by #1713
Assignees
Labels
bug Something isn't working

Comments

@Leviathangk
Copy link

tdesign-mobile-vue 版本

1.7.0

重现链接

No response

重现步骤

案例

20241231_173605

问题

只要 t-checkbox-group 标签有 options 选项,那么通过 disabled 禁用的时候就会失效

代码

<template>
    <h1>提交后会被禁用</h1>
    <!-- 选择一个提交后会被禁用 -->
    <t-checkbox-group :disabled="disableCheckBox1" :max="maxChoice">
        <t-checkbox value="checkbox1" label="选项禁用-已选" />
        <t-checkbox value="checkbox2" label="选项禁用-默认" />
    </t-checkbox-group>
    <t-button @click="change1">切换状态</t-button>
    <t-button @click="submit1">模拟提交</t-button>

    <h1>提交后不会被禁用</h1>

    <!-- 选择一个提交后不会被禁用 -->
    <t-checkbox-group :options="VoteGroup" :disabled="disableCheckBox2" :max="maxChoice">
    </t-checkbox-group>
    <t-button @click="change2">切换状态</t-button>
    <t-button @click="submit2">模拟提交</t-button>
</template>
<script setup>
import { ref } from 'vue';
const disableCheckBox1 = ref(false);
const disableCheckBox2 = ref(false);
const maxChoice = ref(1);
const VoteGroup = ref([
    { label: '选项 1', value: 'checkbox1' },
    { label: '选项 2', value: 'checkbox2' },
]);
const change1 = function () {
    disableCheckBox1.value = !disableCheckBox1.value;
};

const submit1 = () => {
    disableCheckBox1.value = true;
    maxChoice.value = 0;
    console.log('submit');
}

const change2 = function () {
    disableCheckBox2.value = !disableCheckBox2.value;
};

const submit2 = () => {
    disableCheckBox2.value = true;
    maxChoice.value = 0;
    console.log('submit');
}
</script>

期望结果

添加 options 的时候,也应该可以禁用

实际结果

添加 options 的时候,也应该可以禁用

框架版本

No response

浏览器版本

No response

系统版本

No response

Node版本

No response

补充说明

No response

Copy link
Contributor

👋 @Leviathangk,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@anlyyao anlyyao self-assigned this Jan 6, 2025
@anlyyao anlyyao added the bug Something isn't working label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants