我遇到了离子3的一个奇怪问题。我在登录我的应用程序时为用户启用了iOS钥匙串。它只会在使用钥匙串后单击输入后填充值。
我的意见:
<input
name="login_email"
id="user-text-field"
autocomplete="username"
type="email"
class="input-no-bottom-border"
placeholder="Email"
(change)="socialLoginProvider.loginEmail = $event.target.value"
[(ngModel)]="socialLoginProvider.loginEmail"
>
基本上当他们点击键盘上的钥匙串按钮时,它会按预期运行,但一旦他们返回应用程序,输入仍然是空白的,直到用户点击其中一个然后它触发(change)
并更新允许用户登录的值。
Ionic 3没有检测到变化,是一个已知的错误,已在v4中修复。为了解决这个问题,我设置了一个功能来检测点击的变化。我用过ChangeDetectorRef.detectChanges()
(tap)="createDetector()"
detector;
detectChanges() {
return setInterval(() => {
this.changes.detectChanges();
}, 500);
}
createDetector() {
this.detector = this.detectChanges();
}
destroyDetector() {
clearInterval(this.detector);
}
我在方法完成时使用clearInterval来清理间隔,因此它不会持续运行。