[新增] input 组件

This commit is contained in:
就眠仪式 2021-09-28 11:44:53 +08:00
parent 4e2d9c0f4b
commit af7f672852
2 changed files with 26 additions and 4 deletions

View File

@ -1,7 +1,7 @@
::: demo ::: demo
<template> <template>
<lay-input v-model="data"></lay-input>{{data}} <lay-input v-model="data"></lay-input>
</template> </template>
<script> <script>
@ -19,4 +19,25 @@ export default {
} }
</script> </script>
:::
::: demo
<template>
<lay-input placeholder="请输入密码"></lay-input>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
return {
}
}
}
</script>
::: :::

View File

@ -1,5 +1,5 @@
<template> <template>
<input :type="type" :value="modelValue" :name="name" class="layui-input" @input="updateValue"/> <input :type="type" :value="modelValue" :placeholder="placeholder" :name="name" class="layui-input" @input="updateValue"/>
</template> </template>
<script setup name="LayInput" lang="ts"> <script setup name="LayInput" lang="ts">
@ -10,12 +10,13 @@ const props =
name?: string name?: string
type?: string type?: string
modelValue?: string modelValue?: string
placeholder?: string
}>() }>()
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
const updateValue = function(event: unknown,value: unknown) { const updateValue = function(event: InputEvent) {
emit('update:modelValue', value) emit('update:modelValue', (event.target as HTMLInputElement).value)
} }
</script> </script>