修复 src 结构

This commit is contained in:
就眠儀式
2022-01-22 21:30:17 +08:00
parent 96bb84020b
commit d0debbb1b2
186 changed files with 251 additions and 251 deletions

View File

View File

@@ -0,0 +1,9 @@
import type { App } from "vue";
import Component from "./index.vue";
import type { IDefineComponent } from "../type/index";
Component.install = (app: App) => {
app.component(Component.name || "LaySwitch", Component);
};
export default Component as IDefineComponent;

View File

@@ -0,0 +1,57 @@
<script lang="ts">
export default {
name: "LaySwitch",
};
</script>
<script setup lang="ts">
import { defineProps, defineEmits, computed } from "vue";
import "./index.less";
export interface LaySwitchProps {
disabled?: boolean;
activeText?: string;
modelValue?: boolean;
inactiveText?: string;
}
const props = withDefaults(defineProps<LaySwitchProps>(), {
disabled: false,
activeText: "启用",
inactiveText: "禁用",
});
const emit = defineEmits(["update:modelValue", "change"]);
const isActive = computed({
get() {
return props.modelValue;
},
set(val) {
emit("change", val);
emit("update:modelValue", val);
},
});
const handleClick = function () {
if (!props.disabled) {
isActive.value = !isActive.value;
}
};
</script>
<template>
<span @click.stop="handleClick">
<div
class="layui-unselect layui-form-switch"
:class="{
'layui-disabled': disabled,
'layui-form-onswitch': isActive,
'layui-checkbox-disbaled': disabled,
}"
>
<em>{{ isActive == true ? activeText : inactiveText }}</em>
<i></i>
</div>
</span>
</template>