chore: update

This commit is contained in:
xiaoxian521 2024-03-31 12:34:30 +08:00
parent db2b59ed51
commit 6b351d75c7
2 changed files with 8 additions and 12 deletions

View File

@ -34,11 +34,11 @@ const props = {
type: Boolean, type: Boolean,
default: false default: false
}, },
/** 控件尺寸 */ /** 控件尺寸 */
size: { size: {
type: String as PropType<"small" | "default" | "large"> type: String as PropType<"small" | "default" | "large">
}, },
/** 是否global禁用默认false */ /** 是否全局禁用,默认 `false` */
disabled: { disabled: {
type: Boolean, type: Boolean,
default: false default: false
@ -62,8 +62,7 @@ export default defineComponent({
: ref(0); : ref(0);
function handleChange({ option, index }, event: Event) { function handleChange({ option, index }, event: Event) {
if (props.disabled) return; if (props.disabled || option.disabled) return;
if (option.disabled) return;
event.preventDefault(); event.preventDefault();
isNumber(props.modelValue) isNumber(props.modelValue)
? emit("update:modelValue", index) ? emit("update:modelValue", index)
@ -138,9 +137,10 @@ export default defineComponent({
style={{ style={{
background: background:
curMouseActive.value === index ? segmentedItembg.value : "", curMouseActive.value === index ? segmentedItembg.value : "",
color: color: props.disabled
!option.disabled && ? null
(curIndex.value === index || curMouseActive.value === index) : !option.disabled &&
(curIndex.value === index || curMouseActive.value === index)
? isDark.value ? isDark.value
? "rgba(255, 255, 255, 0.85)" ? "rgba(255, 255, 255, 0.85)"
: "rgba(0,0,0,.88)" : "rgba(0,0,0,.88)"

View File

@ -241,11 +241,7 @@ watch(size, val => (dynamicSize.value = size.value));
<Segmented :options="optionsDisabled" :size="dynamicSize" /> <Segmented :options="optionsDisabled" :size="dynamicSize" />
<el-divider /> <el-divider />
<p class="mb-2">全局禁用</p> <p class="mb-2">全局禁用</p>
<Segmented <Segmented :options="optionsBasis" :size="dynamicSize" disabled />
:options="optionsDisabled"
:size="dynamicSize"
:disabled="true"
/>
<el-divider /> <el-divider />
<p class="mb-2">block 属性(将宽度调整为父元素宽度)</p> <p class="mb-2">block 属性(将宽度调整为父元素宽度)</p>
<Segmented :options="optionsBlock" block :size="dynamicSize" /> <Segmented :options="optionsBlock" block :size="dynamicSize" />