Ionic TextFile清除按钮键盘行为iOS



我的Ionic应用程序中有一个文本输入,在同一跨度中有两个按钮。第一个按钮用于进行搜索,第二个按钮用于清除文本输入。当我点击清除按钮,文本输入被清除,键盘重新出现,但文本字段没有焦点时,我看到了奇怪的行为。

有人能帮我确保在清除文本后,文本输入仍然有焦点吗?非常感谢。

<form class="list">
  <span class="item item-input-inset">
    <label class="item-input-wrapper address-label" name="addressLabel">
      <i class="icon ion-ios-search placeholder-icon" ng-show="!address.length"></i>
      <input type="text" class="address-input" placeholder="Search By Address" ng-model="address" autocomplete="off" autocorrect="off" autocapitalize="off">
    </label>
    <button type="submit" id="button1" class="button button-small custom-btn ion-search" ng-click="search(address)" ng-show="address.length"></button>
    <button ng-click="address = ''" class="button button-small custom-btn ion-close-round" ng-show="address.length"></button>
  </span>
</form>

看看离子框架论坛上的这篇文章。看起来这会起作用,给你一种更本土的外观和感觉。

<div class="list list-inset">
   <div class="item item-input">
      <input type="text" placeholder="mail stop"
            name="mail_stop_name"
      >
      <i class="icon ion-ios-close placeholder-icon"
         data-tap-disabled="true"  on-touch="formData.mail_stop_name = ''"></i>
   </div>
</div>

参考编号:https://forum.ionicframework.com/t/clear-button-inside-input-causes-input-to-loose-focus/17016

最新更新