Files
Nexior/src/components/chat/InputBox.vue
T
2023-09-30 20:32:00 +08:00

71 lines
1.2 KiB
Vue

<template>
<div class="input-box">
<el-input
v-model="value"
:rows="2"
type="textarea"
placeholder="Please input"
@keydown.enter.exact.prevent="onSubmit"
/>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { ElInput, ElButton } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { ROUTE_CHAT_INDEX } from '@/router/constants';
export default defineComponent({
name: 'InputBox',
components: {
ElInput,
ElButton,
FontAwesomeIcon
},
props: {
modelValue: {
type: String,
required: true
}
},
emits: ['update:modelValue', 'submit'],
data() {
return {
value: this.modelValue
};
},
watch: {
value(val) {
this.$emit('update:modelValue', val);
},
modelValue(val) {
if (val !== this.value) {
this.value = val;
}
}
},
methods: {
onSubmit() {
this.$emit('submit', this.value);
}
}
});
</script>
<style lang="scss" scoped>
.sidebar {
display: flex;
flex-direction: column;
align-items: flex-end;
.top {
display: flex;
flex-direction: column;
}
.bottom {
display: flex;
flex-direction: column;
}
}
</style>