in ionic changing route causes “TypeError: Cannot

2019-09-16 18:04发布

In the following, when I click on "search icon", the following pops up in console

TypeError: Cannot read property 'scrollTo' of null
at http://localhost:8100/lib/ionic/js/ionic.bundle.js:39909:17
at wrappedCallback (http://localhost:8100/lib/ionic/js/ionic.bundle.js:19197:81)
at http://localhost:8100/lib/ionic/js/ionic.bundle.js:19283:26
at Scope.$eval (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20326:28)
at Scope.$digest (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20138:31)
at Scope.$apply (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20430:24)
at http://localhost:8100/lib/ionic/js/ionic.bundle.js:21938:36
at completeOutstandingRequest (http://localhost:8100/lib/ionic/js/ionic.bundle.js:12022:10)
at http://localhost:8100/lib/ionic/js/ionic.bundle.js:12330:7

I have the following in body tag

<ion-header-bar class="logo-bar">
    <button class="button button-clear">
        <a ui-sref="root.home"><img class="pull-left" src="img/X.png"></a>
    </button>
    <h1 class="title">
        <a ui-sref="root.search" class="icon ion-search" nav-clear></a>
    </h1>
</ion-header-bar>

<ion-nav-view name="rootContent" class="main-body" animation="slide-left-right">
</ion-nav-view>

My home page rootContent content is as follows:

<ion-side-menus>
    <ion-side-menu-content>
        <ion-nav-bar class="app-menu bar-stable" animation="nav-title-slide-ios7" title="">
        </ion-nav-bar>
        <ion-view name="mainContent">
            <ion-content>
                This tag breaks click on SEARCH. Remove ion-content and it will work OK
            </ion-content>
        </ion-view>
    </ion-side-menu-content>
</ion-side-menus>

If I were to remove ion-content tag in the above, the error disappears. I am wondering what's wrong with it and how to fix it.

--edit

The search click plugs in the below in rootContent, transitioning to this is where it breaks:

<ion-view>
  <div class="list list-inset">
    <label class="item item-input">
        <i class="icon ion-search placeholder-icon"></i>
        <input type="text" placeholder="Search" ng-model="searchTerm" ng-change="doSearch(searchTerm)">
    </label>
  </div>
 </ion-view>

1条回答
倾城 Initia
2楼-- · 2019-09-16 19:01

This is a bug in Ionic beta 12.

Its fixed in the nighly build (ionic beta 13)

Download Nightly Build

Nightly build changlog

Read more about the bug

查看更多
登录 后发表回答