【问题标题】:Running app in ionic serve is fine but not with ionic build在离子服务中运行应用程序很好,但不能使用离子构建
【发布时间】:2016-09-27 13:13:39
【问题描述】:

我是离子新手。当我需要多页上的后退按钮,在标签页和非标签页之间切换时,我遇到了问题。我强制后退按钮出现在某个页面上。它按预期显示。但它是错误的。所以我通过为我的原始页面创建一个父母来修复它,我将它命名为“主”。然后我将现有页面的其余部分路由到主页,当我使用“ionic serve”命令时一切正常。所以我用“ionic build ios”测试我的应用程序,但我看到的唯一页面是主页而不是子视图。

我检查了我是否将我的主页配置设置为 abstract: true 并且我做到了。如果我的语法有误,我的应用程序在我使用“离子服务”时就根本无法运行。我一无所知。

这是我的配置代码

.config(function($stateProvider, $urlRouterProvider) {
  $stateProvider
    .state('main', {
      url: "",
      abstract: true,
      templateUrl: '/templates/main.html'
    })
    .state('main.tabs', {
      url: '/tab',
      abstract: true,
      views : {
        'main-content' : {
          templateUrl: '/templates/tabs.html'
        }
      }
    })
    .state('main.tabs.pageI', {
      url: '/pageI',
      views : {
        'Page_1' : {
          templateUrl: 'templates/pageI.html',
          controller: 'EventController'
        }
      }
    })
    .state('main.tabs.pageII', {
      url: '/pageII',
      views : {
        'Page_2' : {
          templateUrl : 'templates/pageII.html',
          controller : 'EventController'
        }
      }
    })
    .state('main.tabs.pageIII', {
      url: '/pageIII',
      views : {
        'Page_3' : {
          templateUrl : 'templates/pageIII.html'
        }
      }
    })
    .state('main.tabs.sub', {
      url: '/sub',
      views : {
        'Page_1' : {
          templateUrl : 'templates/sub.html',
          controller: 'AllController'
        }
      }
    })
    .state('main.info', {
      url: '/info/:aId',
      views : {
        'main-content' : {
          templateUrl: 'templates/Info.html',
          controller: 'SingleController'
        }
      }
    })
    .state('main.user', {
      url: '/user/:username',
      views : {
        'main-content' : {
          templateUrl : 'templates/user.html',
          controller : 'UserController'
        }
      }
    });
    $urlRouterProvider.otherwise('/tab/PageI');
})

这是我运行“ionic serve --lab”时的截图 ionic serve --lab

这是我运行“ionic emulate ios”时的屏幕截图 ionic build ios

【问题讨论】:

  • 你需要尝试运行时调试,尝试关注docs.ionic.io/docs/safari-inspector
  • 这很奇怪,当我使用“ionic run ios -l”时,一切正常。但是如果我使用“ionic run ios -l -c -s”它会抛出一个错误,(错误代码 65)。

标签: ios angularjs ionic-framework ionic-view


【解决方案1】:

我觉得这很尴尬。

但我发现了错误。在 main 和 tabs 的 templateUrl 中。我写“/templates/main.html”和“/templates/tabs.html”。浏览器自动接受 '/templates' 作为 'templates' 目录。但在离子中不是。我将我的代码更改为“templates/main.html”和“templates/tabs.html”,现在它就像魅力一样工作。

【讨论】:

    猜你喜欢
    • 2016-09-12
    • 2018-03-01
    • 2020-05-15
    • 2017-05-30
    • 2018-09-22
    • 2019-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多