【问题标题】:How to go to next input by tapping next key on an iPhone/iPad with Ionic1?如何通过使用 Ionic1 在 iPhone/iPad 上点击下一个键进入下一个输入?
【发布时间】:2019-02-24 11:24:03
【问题描述】:

键盘没有显示下一个按钮以跳转到下一个输入字段。我已经尝试过这个解决方案,但没有奏效

 <div>        
    <input id="in" class="text-center col-33" type="number" ng-model="ngModel" ng-change="change()" (keyup.enter)="handleLogin()">
    </div>    


handleLogin() {
        e.preventDefault();
        var input = document.getElementById('in');
        input.focus();     
}

任何人都可以解决这个问题

【问题讨论】:

    标签: ios iphone ionic-framework keyboard


    【解决方案1】:

    如果您在表单中有两个或更多输入,并且想要使用附件栏,请添加:

    Keyboard.hideFormAccessoryBar(false);
    

    然后您应该查看以下内容:

    随着光标上下移动。

    如果你想改变 (keyup.enter)= 的输入,那么你应该像我接下来解释的那样调用 focus() 函数。

    确保在你的 config.xml 中有这个:

    <preference name="KeyboardDisplayRequiresUserAction" value="false" />
    

    然后像你做的那样调用焦点,这个想法是from @oroc

    .factory('focus', function($timeout, $window) {
      return function(id) {
      // timeout makes sure that is invoked after any other event has been triggered.
      // e.g. click events that need to run before the focus or
      // inputs elements that are in a disabled state but are enabled when those events
      // are triggered.
      var element = $window.document.getElementById(id);
      $timeout(function() {
        if(element){
          element.focus();
        }
      });
     };
    })
    

    关键是调用超时和测试,一些延迟或多次调用。

    我调用 focus('') 两次以避免闪烁(键盘隐藏,然后在半秒后显示)。

    【讨论】:

    • 下一个按钮在键盘上不可见,请告诉我如何显示下一个按钮
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-10
    • 2021-07-07
    • 1970-01-01
    • 1970-01-01
    • 2017-06-29
    相关资源
    最近更新 更多