簡體   English   中英

離子導航無法加載頁面

[英]Ionic navigation cannot load a page

我是新來的離子,而我試圖建立一個ion-nav-view ,如圖教程這里 我已經創建了2頁並設置了一個角度conf文件。 加載時,在瀏覽器中出現以下錯誤: XMLHttpRequest cannot load file:///C:/Users/ITAI/Development/Ionic/LaughWithMe/www/templates/register.html. Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https, chrome-extension-resource. XMLHttpRequest cannot load file:///C:/Users/ITAI/Development/Ionic/LaughWithMe/www/templates/register.html. Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https, chrome-extension-resource.

app.js:

angular.module('myApp', ['ionic'])


.config(function ($stateProvider,$urlRouterProvider) {
// Set and define states
$stateProvider
    .state('register', {
        url: '/register',
        templateUrl: 'templates/register.html'
    });
})

index.html的:

    <!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="cordova.js"></script>

    <!-- your app's js -->
    <script src="js/app.js"></script>
</head>

<body ng-app="myApp">

    <ion-nav-bar></ion-nav-bar>
    <ion-nav-view animation="slide-left-right">
    </ion-nav-view>

<!--    <script id="index" type="text/ng-template">
  <!-- The title of the ion-view will be shown on the navbar -->
  <ion-view title="'Home'">
    <ion-content>
      <!-- The content of the page -->
      <a ui-sref="register">Register</a>
    </ion-content>
  </ion-view>
</script>-->

    </body>

</html>

register.html:

<h1> hello world!</h1>

我有一些有關angular的經驗,但是我對此框架感到非常困惑。 我不知道這些指令在哪里以及如何將它們注入到我的HTML頁面中。 我試圖做的是將register頁面鏈接到index.html頁面。 最簡單的方法是。

cors錯誤通常表示您正在運行項目而不使用http serve。 嘗試跑步

ionic serve 
or 
phonegap serve 

從項目的根源開始。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM