javascript - ionic2 input autofocus succeeds on computer, but iOS mobile keyboard does not pop up
高洛峰
高洛峰 2017-06-24 09:43:52
0
1
862

Input automatically gets focus after entering the page. There is no problem in the computer simulation test, but it does not work on the mobile phone and the keyboard does not pop up.
I have basically tried all the online search methods, such as adding <preference name="KeyboardDisplayRequiresUserAction" value="false" />
to config.xml

Or add a delay, such as *.ts

@ViewChild('input') myInput: any;

ngAfterViewInit() {

    setTimeout(() => {
      console.log('focus')
      this.myInput.setFocus();
    }, 2000);

  }

*.html

<ion-input autofocus #input placeholder="input"></ion-input>

I don’t know if you have any other methods.
PS. The WeChat built-in browser and Safari used for the browser do not work. I have tried the WeChat built-in browser WKWebView and UIWebView and the kernel does not work either.

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
Peter_Zhu

You first try calling cordova.plugins.Keyboard.show() directly
If possible, breakpoint to track what is executed after this.myInput.setFocus()

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template