[新增] switch 组件, 解决 timeline 警告
This commit is contained in:
9
src/module/switch/index.ts
Normal file
9
src/module/switch/index.ts
Normal 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
|
||||
33
src/module/switch/index.vue
Normal file
33
src/module/switch/index.vue
Normal 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>
|
||||
Reference in New Issue
Block a user