Skip to content

Commit cd96c1e

Browse files
committed
textarea随着行数增长高度自适应
1 parent bc3f7c5 commit cd96c1e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

resources/js/Pages/Chat.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const regenerate = () => {
105105
<Head title="GeekChat - 支持文字、语音、翻译、画图的聊天机器人"></Head>
106106
<div>
107107
<div class="max-w-5xl mx-auto">
108-
<div class="py-8">
108+
<div class="py-5">
109109
<div class="p-3 sm:p-5 flex items-center justify-center">
110110
<div>
111111
<div class="flex items-center justify-center space-x-2"><img
@@ -209,8 +209,9 @@ const regenerate = () => {
209209
<form class="grid grid-cols-1 gap-2 md:flex md:items-start md:justify-center md:space-x-2 mb-2"
210210
@submit.prevent="chat">
211211
<textarea required id="chat-input-textbox" placeholder="输入你的问题/翻译内容/图片描述..." name="prompt"
212-
autocomplete="off" v-model="form.prompt" style="height: 40px !important;"
213-
class="block w-full rounded-md border-0 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:py-1.5 sm:text-sm sm:leading-6 resize-y"></textarea>
212+
autocomplete="off" v-model="form.prompt"
213+
:style="{ height: (form.prompt && form.prompt.split('\n').length > 1) ? form.prompt.split('\n').length * 2 + 'rem' : '40px' }"
214+
class="block w-full rounded-md border-0 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:py-1.5 sm:text-sm sm:leading-6 resize-none"></textarea>
214215
<div class="flex space-x-2">
215216
<button
216217
:class="{ 'flex items-center justify-center px-4 py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-md text-sm md:text-base': true, 'opacity-25': isTyping }"

0 commit comments

Comments
 (0)