离子变化位置不起作用

 mobiledu2502924293 发布于 2023-01-12 17:09

我是离子的新手(在angularjs中稍微少一些).

我正试图在两个视图之间进行简单的切换:

HTML


    
    
      
        Back
      
    

    
    
    
    
    
    
  

APP.js

.config(function($stateProvider, $urlRouterProvider) {

  // Ionic uses AngularUI Router which uses the concept of states
  // Learn more here: https://github.com/angular-ui/ui-router
  // Set up the various states which the app can be in.
  // Each state's controller can be found in controllers.js
  $stateProvider


    .state('intro', {
      url: '/intro',
      views: {
        'intro': {
          templateUrl: 'templates/intro.html',
          controller: 'IntroCtrl'
        }
      }
    })
    .state('login', {
      url: '/login',
      views: {
        'login': {
          templateUrl: 'templates/login.html',
          controller: 'LoginCtrl'
        }
      }
    })
  $urlRouterProvider.otherwise('/intro');

});

Controllers.js

angular.module('starter.controllers', [])

.controller('IntroCtrl', function($scope,$location) {
    $location.url("/login");

})
.controller('LoginCtrl', function($scope,$location) {

})

介绍正确显示,但当它尝试将位置更改为"login.html"时,它说:

TypeError: Cannot read property 'querySelectorAll' of undefined
    at cancelChildAnimations (http://localhost:8000/www/lib/ionic/js/ionic.bundle.js:30611:21)
    at Object.leave (http://localhost:8000/www/lib/ionic/js/ionic.bundle.js:30176:11)
    at Object.leave (http://localhost:8000/www/lib/ionic/js/ionic.bundle.js:38411:24)
    at updateView (http://localhost:8000/www/lib/ionic/js/ionic.bundle.js:41540:31)
    at eventHook (http://localhost:8000/www/lib/ionic/js/ionic.bundle.js:41501:17)
    at Scope.$broadcast (http://localhost:8000/www/lib/ionic/js/ionic.bundle.js:21190:28)
    at $state.transition.resolved.then.$state.transition (http://localhost:8000/www/lib/ionic/js/ionic.bundle.js:33975:22)
    at wrappedCallback (http://localhost:8000/www/lib/ionic/js/ionic.bundle.js:19894:81)
    at http://localhost:8000/www/lib/ionic/js/ionic.bundle.js:19980:26
    at Scope.$eval (http://localhost:8000/www/lib/ionic/js/ionic.bundle.js:20906:28) 

可能是什么问题呢???

谢谢!

1 个回答
  • 试试这个

    angular.module('starter.controllers', [])
    
    .controller('IntroCtrl', function($scope,$state) {
         $state.transitionTo("login");
    
    })
    .controller('LoginCtrl', function($scope,$location) {
    
    })
    

    2023-01-12 17:11 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有