Cordova:不能为我的多页面应用程序添加新页面

Cordova : Can't add new page for my multi-page application

本文关键字:应用程序 添加 新页面 不能 我的 Cordova      更新时间:2023-09-26

我是cordova新手。我试图建立一个多页的应用程序。在我创建项目之后,它只有一个index.html文件。我编辑了这个页面,并制作了我的第一页。现在我很困惑,如何在该html文件中添加我的第二页。我创建了一个按钮,当我点击这个按钮时,我需要转到新的页面。我在我的ubuntu系统中使用cordova。我是一个编程初学者。谁能告诉我这个问题的解决方法?我使用cordova+ionic来构建页面,因为我不知道如何仅使用cordova创建页面。我用离子框架制作了这个页面。但是不知道如何添加新页面。

<!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="starter">
    <ion-pane>
      <ion-header-bar class="bar-stable">
        <h1 class="title">TREASURE HUNT</h1>
      </ion-header-bar>
      <ion-content>
<!--section id="first_page"-->
<div class="list card">
<div class="item item-body">
    <img class="small-image" src="treasurehunt.png" height="200dp" width="fill_parent"><br/>
	
<div class="list">
  <label class="item item-input">
    
    <input type="text" placeholder="Email">                                
  </label>
  <label class="item item-input">
    
    <input type="password" placeholder="Password">
  </label>
</div>
<a class="button icon-right ion-chevron-right button-calm" href="#clients">Login
</a></br></br><a href="#">Sign Up</a></div></div></ion-content>
    </ion-pane>
</body>
</html>

你正在使用Ionic框架。他们提供了自己的文档,甚至还提供了如何创建带导航的多视图应用程序的示例。


旧答案:

Cordova与使用一个非常简单的linux服务器没有太大的不同。

使用锚元素使用相对URL链接到第二页。

<a class="button icon-right ion-chevron-right button-calm" ref="clients.html">Login</a>
                                                                       ^
                                                                       |
                                                                       notice the .html?

最重要的是要记住,Cordova是一个将你的HTML/JS/CSS放到移动设备上的工具。

在App中添加页面就像在网站中添加页面一样。

创建另一个HTML文档,并使用锚标记链接到它。您需要包含该页面的所有相关脚本和样式。