[新增] form-item 组件

This commit is contained in:
就眠仪式 2021-10-04 07:44:31 +08:00
parent 8f3b104c8b
commit 2fb6d43e39
5 changed files with 36 additions and 4 deletions

View File

@ -24,7 +24,7 @@ export default {
::: demo ::: demo
<template> <template>
<lay-input placeholder="请输入密码"></lay-input> <lay-input placeholder="请输入密码" type="password"></lay-input>
</template> </template>
<script> <script>

View File

@ -43,6 +43,7 @@ import LaySelect from './module/select/index'
import LaySelectOption from './module/selectOption/index' import LaySelectOption from './module/selectOption/index'
import LayScroll from './module/scroll/index' import LayScroll from './module/scroll/index'
import LayEmpty from './module/empty/index' import LayEmpty from './module/empty/index'
import LayFormItem from './module/formItem/index'
const components: Record<string, IDefineComponent> = { const components: Record<string, IDefineComponent> = {
LayRadio, LayRadio,
@ -84,7 +85,8 @@ const components: Record<string, IDefineComponent> = {
LaySelect, LaySelect,
LayScroll, LayScroll,
LaySelectOption, LaySelectOption,
LayEmpty LayEmpty,
LayFormItem
} }
const install = (app: App, options?: InstallOptions): void => { const install = (app: App, options?: InstallOptions): void => {
@ -140,6 +142,7 @@ export {
LayScroll, LayScroll,
LaySelectOption, LaySelectOption,
LayEmpty, LayEmpty,
LayFormItem,
install, install,
} }

View File

@ -1,9 +1,8 @@
<template> <template>
<form class="layui-form"> <form class="layui-form">
<slot></slot> <slot></slot>
</form> </form>
</template> </template>
<script setup name="LayForm" lang="ts"> <script setup name="LayForm" lang="ts">
</script> </script>

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 || 'LayFormItem', Component)
}
export default Component as IDefineComponent

View File

@ -0,0 +1,21 @@
<template>
<div class="layui-form-item">
<label class="layui-form-label">{{ label }}</label>
<div :class="[mode ? 'layui-input-' + mode : '']" class="layui-input-block">
<slot></slot>
</div>
</div>
</template>
<script setup name="LayFormItem" lang="ts">
import { defineProps, withDefaults } from 'vue'
const props = withDefaults(
defineProps<{
mode?: string
label?: string
}>(),
{
mode: 'block',
}
)
</script>