1. 阻止 ios 默认行为,键盘弹出,浮在页面上
<div v-show="showKeyboard">
<!-- 遮罩 -->
<div class="fixed inset-0 bg-black/50 z-98" @click="handleClose"></div>
<!-- 输入框 -->
<div
class="fixed left-0 right-0 z-99 bg-white transition-all duration-500"
:style="{ bottom: keyboardHeight + 'px' }"
>
<div class="flex gap-2 p-3">
<!-- 真实 input 2:负责输入 -->
<input
ref="realInputRef"
v-model="message"
type="text"
placeholder="说点什么..."
class="flex-1 bg-gray-100 rounded-full px-4 py-2"
style="font-size: 16px"
@blur="handleBlur"
/>
<button
@click="handleSend"
class="px-4 py-2 bg-blue-500 text-white rounded-full"
>
发送
</button>
</div>
</div>
</div>
2026/1/14大约 1 分钟