1

我是离子新手。我正在尝试使用离子标签。以下是我的代码:-

// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
angular.module('starter', ['ionic'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {
      // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
      // for form inputs)
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);

      // Don't remove this line unless you know what you are doing. It stops the viewport
      // from snapping when text inputs are focused. Ionic handles this internally for
      // a much nicer keyboard experience.
      cordova.plugins.Keyboard.disableScroll(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
})
.config(function($stateProvider, $urlRouterProvider){
	$stateProvider
    .state('abc', {
      url: "/abc",
      abstract: false,
      templateUrl: "abc.html"
    })
	.state('def', {
      url: "/def",
      abstract: false,
      templateUrl: "def.html"
    })
	.state('main', {
      url: "/main",
      abstract: false,
      templateUrl: "main.html"
    });
	$urlRouterProvider.otherwise(function ($injector, $location) {
		var $state = $injector.get("$state");
		$state.go("main");
	  });
});
<!-- 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 rel="manifest" href="manifest.json">

    <!-- un-comment this code to enable service worker
    <script>
      if ('serviceWorker' in navigator) {
        navigator.serviceWorker.register('service-worker.js')
          .then(() => console.log('service worker installed'))
          .catch(err => console.log('Error', err));
      }
    </script>-->

    <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">
	
	<script type="text/ng-template" id="def.html">
		<ion-view>
			<ul class="list">
				<h1><a class="item">abc</a></h1>
				<h2><a class="item">def</a></h2>
			</ul>
		</ion-view>
	</script>
	
	<script type="text/ng-template" id="main.html">
		<ion-view>
			<ion-tabs class="tabs-icon-top tabs-balanced">				
				<ion-tab title="Dashboard" icon="ion-home" href="#/abc">
				  <ion-nav-view name="dash-tab"></ion-nav-view>
				</ion-tab>
				
				<ion-tab title="Public" icon="ion-earth" href="#/def">
				  <ion-nav-view name="public-tab"></ion-nav-view>
				</ion-tab>
				
				<ion-tab title="Secret" icon="ion-nuclear" href="#/abc">
				  <ion-nav-view name="admin-tab"></ion-nav-view>
				</ion-tab>
			
		  </ion-tabs>
		</ion-view>
	</script>
	
	<script type="text/ng-template" id="abc.html">
		<ion-view>
			<ion-content class="padding">
				<h1> Sub header example 1</h1>
				<h1> Sub header example 2</h1>
				<h1> Sub header example 3</h1>
				<h1> Sub header example 4</h1>
				<h1> Sub header example 5</h1>
				<h1> Sub header example 6</h1>
				<h1> Sub header example 7</h1>
				<h1> Sub header example 8</h1>
				<h1> Sub header example 9</h1>
				<h1> Sub header example 10</h1>
				<h1> Sub header example 11</h1>
				<h1> Sub header example 12</h1>
				<h1> Sub header example 13</h1>
				<h1> Sub header example 14</h1>
				<h1> Sub header example 15</h1>
			</ion-content>
		</ion-view>
	</script>
  
    <ion-side-menus>
		<ion-side-menu-content>
			<ion-nav-bar class="bar-positive">
				<ion-nav-buttons side="left">
					<button class="button button-icon ion-navicon" menu-toggle="left"></button>
				</ion-nav-buttons>
				<ion-nav-buttons side="right">
					<button class="button button-icon ion-search"></button>
					<button class="button button-icon ion-ios-email"></button>
					<button class="button button-icon ion-ios-person"></button>
				</ion-nav-buttons>
				<h1 class="title"> Main Nav bar</h1>
			</ion-nav-bar>
			<ion-header-bar class="bar bar-balanced bar-subheader">
				<button class="button button-icon icon ion-chevron-left"></button>
				<button class="button">ABC</button>
				<h2 class="title">Sub Header</h2>
			</ion-header-bar>
			<ion-footer-bar class="bar bar-footer bar-positive">
				Footer
			</ion-footer-bar>
			<ion-nav-view>
			</ion-nav-view>
		</ion-side-menu-content>
		<ion-side-menu side="left">
			<ul class="list">
				<a class="item" href="#/abc">first</a>
				<a class="item" href="#/def">second</a>
			</ul>
		</ion-side-menu>
	</ion-side-menus>
  </body>
</html>

我希望在 UI 中呈现选项卡,但问题是,选项卡栏和选项卡根本没有出现。

我不知道,我在哪里失踪。为糟糕的英语道歉。提前致谢。

4

1 回答 1

0

我认为您忘记添加,因此无法在应用程序中呈现标题。PS 不要在 IONIC 中使用 HTML 标签。使用 IONIC 特定代码。

<ion-header>
 <ion-navbar>
   <button ion-button menuToggle>
    <ion-icon name="menu"></ion-icon>
    </button>
    <ion-title>Page Two</ion-title>
</ion-navbar>
</ion-header>
于 2017-03-12T06:29:15.073 回答