[新增] switch 组件, 解决 timeline 警告

This commit is contained in:
就眠仪式
2021-09-28 15:01:12 +08:00
parent 0a664e5b47
commit 0180e9f4f5
7 changed files with 97 additions and 6 deletions

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,33 @@
<template>
<span @click="handleClick">
<div class="layui-unselect layui-form-switch"
:class="{
'layui-form-onswitch': modelValue == true,
'layui-checkbox-disbaled layui-disabled': disabled
}">
<em>{{modelValue == true ? "启用" : "禁用"}}</em>
<i></i>
</div>
</span>
</template>
<script setup name="LaySwitch" lang="ts">
import { defineProps, defineEmits } from '@vue/runtime-core'
const props =
defineProps<{
modelValue: boolean
disabled?: boolean
}>()
const emit = defineEmits(['update:modelValue'])
const handleClick = function() {
if(props.disabled) {
return false
}
emit('update:modelValue',!props.modelValue)
}
</script>