所以我最近开始使用离子框架,当我尝试制作一个Android应用程序并在Chrome中运行它第一次它是快速和快速的。然后我添加了一个按钮,它将你带到另一个屏幕,在两个屏幕上都有导航栏和侧面菜单以及自定义字体,这样我的应用程序就变得很慢了!现在我甚至无法点击按钮将我带到下一个屏幕。该应用程序甚至不进行服务器调用。它在firefox中运行得相当快,但是如果我使用离子发送--lab应用程序仍然落后于那里。此外,我添加了自定义字体,当我加载到一个实际的Android设备时显示我第一次启动应用程序,但它永远不会再次显示在第二次启动。我附上了两个屏幕的代码。
`<!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">
-->
<!-- your app's js -->
</head>
<body ng-app="starter">
<ion-pane class="customBackground">
<div class="harpee" style="font-family: Freehand521, sans-serif">Harpee</div>
<div class="motto">
<p>A Culture of Happiness and Hope</p>
</div>
<div class="logIn">
<h1>Log In</h1>
</div>
<div class="logInForm">
<div class="list list-inset">
<label class="item item-input">
<input type="text" placeholder="Username">
</label>
</div>
<div class="list list-inset formSpacing">
<label class="item item-input">
<input type="password" placeholder="Password">
</label>
</div>
<a href="homeView.html">
<button class="button button-positive customButton">
Sign In
</button>
</a>
<div class="customText">
<p>Forgot your Password?</p>
<p>Sign Up</p>
</div>
</div>
</ion-pane>
<!-- 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>
<script src="js/app.js"></script>
</body>
</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/home.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">
-->
<!-- your app's js -->
<!--Fonts-->
</head>
<body ng-app="starter">
<ion-pane>
<ion-side-menus>
<ion-side-menu-content>
<ion-nav-bar class="bar bar-header bar-positive">
<ion-nav-buttons side="left">
<button menu-toggle="left" class="button button-icon icon ion-navicon"></button>
</ion-nav-buttons>
<ion-nav-buttons side="right">
<i class="icon ion-ios7-search button button-clear" ng-click="#"></i>
</ion-nav-buttons>
</ion-nav-bar>
<ion-tabs class="tabs-positive">
<ion-tab icon="ion-home" ui-sref="home">
<ion-nav-view name="home"></ion-nav-view>
</ion-tab>
<ion-tab icon="ion-compose" ui-sref="talk">
<ion-nav-view name="talk"></ion-nav-view>
</ion-tab>
<ion-tab icon="ion-social-reddit" ui-sref="hdi">
<ion-nav-view name="hdi"></ion-nav-view>
</ion-tab>
<ion-tab icon="ion-person" ui-sref="you">
<ion-nav-view name="you"></ion-nav-view>
</ion-tab>
</ion-tabs>
</ion-side-menu-content>
<ion-side-menu side="left">
<header class="bar bar-header bar-stable">
<h1 class="title">Menu</h1>
</header>
<ion-content class="has-header">
<ion-list>
<ion-item class="item item-avatar">
<img src="img/3.jpg">
<h2>User Name</h2>
<p>Brief Bio</p>
<!--This is the actual code to be used, to fetch user data and display as in the above code-->
<!--<img ng-src="{{item.img}}">-->
<!--<h2>{{item.title}}</h2>-->
<!--<p>{{item.description}}</p>-->
</ion-item>
<ion-item nav-clear menu-close ng-click="#">
<i class="icon ion-person" ng-click="#">
My Profile
</i>
</ion-item>
<ion-item nav-clear menu-close ng-click="#">
<i class="icon ion-person-stalker" ng-click="#">
Forums
</i>
<span class="badge badge-assertive">0</span>
</ion-item>
<ion-item nav-clear menu-close ng-click="#">
<i class="icon ion-loop" ng-click="#">
Connect
</i>
</ion-item>
<ion-item nav-clear menu-close ng-click="#">
<i class="icon ion-gear-a" ng-click="#">
Settings
</i>
</ion-item>
<ion-item nav-clear menu-close ng-click="#">
<i class="icon ion-power" ng-click="#">
Log Out
</i>
</ion-item>
</ion-list>
</ion-content>
</ion-side-menu>
</ion-side-menus>
</ion-pane>
<script type="text/ng-template" id="home.html">
<ion-view title="Home">
<ion-content padding="true">
<div class="list card">
<div class="item item-avatar">
<img src="img/3.jpg">
<h2>Raphael Rigwanzo</h2>
<p>January 30, 2015</p>
</div>
<div class="item item-body">
<img class="full-image" src="img/3.jpg">
<p>
Exciting bootcamp happening in school. Alot of interesting lads here!!
</p>
<p>
<a href="#" class="subdued">1 Like</a>
<a href="#" class="subdued">5 Comments</a>
</p>
</div>
<div class="item tabs tabs-secondary tabs-icon-left">
<a class="tab-item" href="#">
<i class="icon ion-thumbsup"></i>
Like
</a>
<a class="tab-item" href="#">
<i class="icon ion-chatbox"></i>
Comment
</a>
<a class="tab-item" href="#">
<i class="icon ion-share"></i>
Share
</a>
</div>
</div>
</ion-content>
</ion-view>
</script>
<script type="text/ng-template" id="talk.html">
<ion-view title="Talk">
<ion-content padding="true">
<div class="list card">
<div class="item item-avatar">
<img src="img/3.jpg">
<h2>Raphael Rigwanzo</h2>
<p>Developer</p>
</div>
<div class="item item-body">
<input type="text" placeholder="What's on your mind...">
</div>
<div class="item tabs tabs-secondary tabs-icon-left">
<a class="tab-item" href="#">
<i class="icon ion-android-camera"></i>
Upload Photo
</a>
<a class="tab-item" href="#">
<i class="icon ion-ios7-location"></i>
Tag location
</a>
</div>
</div>
<button class="button button-block button-positive">
Post
</button>
</ion-content>
</ion-view>
</script>
<script type="text/ng-template" id="hdi.html">
<ion-view title="HDI">
<ion-content padding="true">
<div class="list card">
<div style="text-align: center;">
<h2>Harpee</h2>
<p>HDI Mascot</p>
</div>
<div class="item item-body" style="text-align: center;">
<img src="#">
</div>
<div class="item tabs tabs-secondary tabs-icon-left">
<a class="tab-item" href="#">
<i class="icon ion-clipboard"></i>
Know Your HDI
</a>
</div>
</div>
</ion-content>
</ion-view>
</script>
<script type="text/ng-template" id="you.html">
<ion-view title="Profile">
<ion-content>
<div class="userStatsBackground">
<div class="profile">
<img class="profilePicture circle" src="img/3.jpg">
<h1>Raphael Rigwanzo</h1>
<p>Developer</p>
</div>
<div class="userStatsFill">
<div class="row userStats">
<div class="col">Talks</div>
<div class="col">Followers</div>
<div class="col">Following</div>
</div>
<div class="row userStats">
<div class="col"><h3>300</h3></div>
<div class="col"><h3>1200</h3></div>
<div class="col"><h3>300</h3></div>
</div>
</div>
</div>
</ion-content>
</ion-view>
</script>
<!-- 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>
<script src="js/app.js"></script>
</body>
</html>`
答案 0 :(得分:0)
您应该只使用一个index.html
来加载js
和css
文件,而不是每个页面。此外,您对id="home.html"
等文件有奇怪的参考。因此,我假设您通过引用其ID来获取包含锚点的页面。这不是离子的工作方式。您应该使用角度控制器来导航和渲染视图。至于你的字体,你如何加载它们?它们是否已加载到Chrome,Firefox?这些链接可能对此有所帮助。
https://blog.nraboy.com/2014/10/use-font-awesome-glyph-icons-ionicframework/ http://forum.ionicframework.com/t/custom-font-usage/4270/9