【发布时间】:2023-03-22 12:08:01
【问题描述】:
我的应用程序 ionic 4 中的键盘有问题。 显示键盘时,页脚中的文本框被隐藏,因此无法看到文本框中的内容。
when the keyboard is displayed
感谢您为我的问题提出解决方案
【问题讨论】:
-
请分享您的标记
-
我已经在帖子中添加了页脚代码
我的应用程序 ionic 4 中的键盘有问题。 显示键盘时,页脚中的文本框被隐藏,因此无法看到文本框中的内容。
when the keyboard is displayed
感谢您为我的问题提出解决方案
【问题讨论】:
我很确定您的应用程序处于全屏模式,如果是这样,请移除全屏模式,因为它不支持 ionic 4 页脚输入。
【讨论】:
您是否尝试过使用普通的<input type="text"> 而不是<ion-input type="text">。在 ionic 3 上,这对我来说很容易解决。
【讨论】:
带电容器的 Ionic 5 的工作解决方案, 在键盘事件上添加监听器,我们可以切换整个 ion-footer 元素来向上或向下变换。 注意 translate3d 键盘高度中的减号。
import { Plugins, KeyboardInfo } from '@capacitor/core';
const { Keyboard } = Plugins;
@ViewChild(IonFooter, { read: ElementRef }) private inputTextArea: ElementRef
ionViewDidEnter() {
Keyboard.addListener('keyboardDidShow', (info: KeyboardInfo) => {
console.log('keyboard will show with height', info.keyboardHeight);
this.inputTextArea.nativeElement.style.setProperty(
'transform',
`translate3d(0, -${info.keyboardHeight}px, 0)`
);
});
Keyboard.addListener('keyboardDidHide', () => {
console.log('keyboard did hide');
this.inputTextArea.nativeElement.style.removeProperty('transform');
});
}
【讨论】: