✨(switch): 新增 loading 与 loading-icon 属性
This commit is contained in:
@@ -19,12 +19,15 @@ export interface LaySwitchProps {
|
||||
onswitchValue?: string | number | boolean;
|
||||
unswitchValue?: string | number | boolean;
|
||||
size?: "lg" | "md" | "sm" | "xs";
|
||||
loadingIcon?: string;
|
||||
loading?: boolean;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<LaySwitchProps>(), {
|
||||
disabled: false,
|
||||
onswitchValue: true,
|
||||
unswitchValue: false,
|
||||
loadingIcon: "layui-icon-loading-one",
|
||||
size: "md",
|
||||
});
|
||||
|
||||
@@ -75,8 +78,13 @@ const styles = computed(() => {
|
||||
<em>{{ isActive == true ? onswitchText : unswitchText }}</em>
|
||||
<span>
|
||||
<div>
|
||||
<slot v-if="isActive" name="onswitch-icon"></slot>
|
||||
<slot v-else name="unswitch-icon"></slot>
|
||||
<template v-if="loading">
|
||||
<i class="layui-icon layui-anim layui-anim-rotate layui-anim-loop" :class="loadingIcon"></i>
|
||||
</template>
|
||||
<template v-else>
|
||||
<slot v-if="isActive" name="onswitch-icon"></slot>
|
||||
<slot v-else name="unswitch-icon"></slot>
|
||||
</template>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user