[新增] 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

@ -65,4 +65,50 @@ export default {
}
</script>
:::
::: demo
<template>
<lay-switch v-model="active"></lay-switch>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const active = ref(true);
return {
active
}
}
}
</script>
:::
::: demo
<template>
<lay-switch v-model="active" disabled></lay-switch>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const active = ref(true);
return {
active
}
}
}
</script>
:::

View File

@ -45,9 +45,9 @@ export default {
<template>
<lay-timeline>
<lay-timeline-item title="2017年layui 里程碑版本 2.0 发布" sample></lay-timeline-item>
<lay-timeline-item title="2016年layui 首个版本发布" sample></lay-timeline-item>
<lay-timeline-item title="2015年layui 孵化" sample></lay-timeline-item>
<lay-timeline-item title="2017年layui 里程碑版本 2.0 发布" simple></lay-timeline-item>
<lay-timeline-item title="2016年layui 首个版本发布" simple></lay-timeline-item>
<lay-timeline-item title="2015年layui 孵化" simple></lay-timeline-item>
</lay-timeline>
</template>

View File

@ -17,7 +17,7 @@
<li><router-link to="/zh-CN/components/block">区块</router-link></li>
<li><router-link to="/zh-CN/components/line">分割</router-link></li>
<li><router-link to="/zh-CN/components/progress">进度</router-link></li>
<li><router-link to="/zh-CN/components/timeline">时间线</router-link></li>
<li><router-link to="/zh-CN/components/timeline">时间</router-link></li>
</ul>
</lay-side>
<lay-body>

View File

@ -26,6 +26,7 @@ import LayLine from "./module/line/index"
import LayTimeline from "./module/timeline/index"
import LayTimelineItem from "./module/timelineItem/index"
import LayTextarea from "./module/textarea/index"
import LaySwitch from "./module/switch/index"
const components: Record<string, IDefineComponent> = {
LayRadio,
@ -50,7 +51,8 @@ const components: Record<string, IDefineComponent> = {
LayLine,
LayTimeline,
LayTimelineItem,
LayTextarea
LayTextarea,
LaySwitch
}
const install = (app: App, options?: InstallOptions): void => {
@ -87,6 +89,7 @@ export {
LayTimeline,
LayTimelineItem,
LayTextarea,
LaySwitch,
install,
}

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>

View File

@ -19,6 +19,6 @@ import { defineProps } from '@vue/runtime-core'
const props =
defineProps<{
title: string
simple: boolean
simple?: boolean
}>()
</script>