微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 ionic 3 Ionic - 当我们向下滚动时,Google 地点的自动完成位置与输入框分离

如何解决在 ionic 3 Ionic - 当我们向下滚动时,Google 地点的自动完成位置与输入框分离

在 ionic 中,我们使用 ionic geolocation for google maps…当我们搜索任何地方时,在搜索框的输入中,然后向下滚动到应用程序然后自动完成也会滚动并与输入搜索框设计分离。我应用了许多 CSS 来附加带有搜索输入的自动完成功能,但无法正常工作。

when scroll then autocomplete detached from search box

下面的代码在网络浏览器中运行良好,但在构建中不起作用。 html 文件

<ion-content class="bglightgray" #content padding>

    <div class="mapView">
        <div class="searchBar">
            <!-- <ion-searchbar placeholder="Search your Location" class="mapSearch" ></ion-searchbar> -->
            <div class="inp-wrap">

                <input id="MapInput" [(ngModel)]="mapname" class="mapSearch cs-mapSearch" type="text" placeholder="Search your Location" #MapInput>

                <div class="closeIcon" (click)="closeSearch()"></div>
                <div class="searchbarIcon"></div>
            </div>

        </div>
        <!-- <img src="assets/imgs/map.jpg" alt=""> -->
        <div #mapContainer id="mapContainer" [ngClass]=" { hideMap: !MapView}"></div>
    </div>
</ion-content>

ts 文件

import { Content,Events } from 'ionic-angular';
export class MapViewPage {
@ViewChild('content') content: Content;
constructor(){
}

    ngAfterViewInit() {
    this.content.ionScroll.subscribe((event) =>  {
      //console.log('scrolled');
        //var pacContainer = document.body.querySelector('.pac-container');
        const pacContainer = document.querySelector<HTMLElement>('.pac-container');
        pacContainer.style.display  = "none";
       });
  }
 }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。