layui/src/module/textarea/index.vue

41 lines
872 B
Vue
Raw Normal View History

2021-09-28 04:41:16 +00:00
<template>
<textarea
:value="modelValue"
:placeholder="placeholder"
:name="name"
:disabled="disabled"
class="layui-textarea"
:class="{ 'layui-disabled': disabled }"
@input="onInput"
@focus="onFocus"
@blur="onBlur"
/>
2021-09-28 04:41:16 +00:00
</template>
<script setup name="LayTextarea" lang="ts">
2021-09-29 09:22:33 +00:00
import { defineProps, defineEmits } from 'vue'
2021-09-28 04:41:16 +00:00
const props = defineProps<{
name?: string
modelValue?: string
placeholder?: string
disabled?: boolean
}>()
2021-09-28 04:41:16 +00:00
const emit = defineEmits(['update:modelValue', 'input', 'focus', 'blur'])
2021-09-28 04:41:16 +00:00
const onInput = function (event: InputEvent) {
const inputElement = event.target as HTMLInputElement
emit('update:modelValue', inputElement.value)
emit('input', inputElement.value)
2021-09-28 04:41:16 +00:00
}
const onFocus = function (event: FocusEvent) {
emit('focus', event)
}
const onBlur = function () {
emit('blur')
}
2021-09-28 04:41:16 +00:00
</script>