feat: 兼容在app上页面滚动与键盘问题

This commit is contained in:
2026-05-11 15:54:28 +08:00
parent 85a61d5bbf
commit 9cd3916ab2
6 changed files with 149 additions and 36 deletions

View File

@@ -33,6 +33,7 @@
confirm-type="send"
v-model="inputMessage"
auto-height
:focus="isFocused"
:confirm-hold="true"
:placeholder="placeholder"
:show-confirm-bar="false"
@@ -322,20 +323,28 @@ const handleTouchEnd = () => {
// 手动聚焦输入框
const focusInput = () => {
if (textareaRef.value) {
textareaRef.value.focus();
}
isFocused.value = true;
nextTick(() => {
if (textareaRef.value) {
textareaRef.value.focus();
}
});
};
// 手动失焦输入框
const blurInput = () => {
isFocused.value = false;
if (textareaRef.value) {
textareaRef.value.blur();
}
nextTick(() => {
uni.hideKeyboard();
});
};
// 暴露方法给父组件
defineExpose({ focusInput });
defineExpose({ focusInput, blurInput });
</script>
<style scoped lang="scss">