gpt4 book ai didi

html - 为什么 ionic 标签没有正确呈现?

转载 作者:太空宇宙 更新时间:2023-11-04 09:01:06 26 4
gpt4 key购买 nike

我是 ionic 的新手(虽然我对 angularJs 有一些了解)。我在 ionic 标签中遇到问题。以下是我的代码:-

// 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){
$urlRouterProvider.otherwise('/home');

$stateProvider

// HOME STATES AND NESTED VIEWS ========================================
.state('home', {
url: '/home',
views: {
'': {
templateUrl: 'partial-home.html'
},
'other@home': {
template: "Hello World! I am other-11."
},
'other': {
template: "Hello World! I am other 12."
}
}
})

// nested list with custom controller
.state('home.list', {
url: '/list',
templateUrl: 'partial-home-list.html',
controller: function($scope) {
$scope.dogs = ['Bernese', 'Husky', 'Goldendoodle'];
}
})

// nested list with just some random string data
.state('home.paragraph', {
url: '/paragraph',
template: '<ion-view view-title="paragraph">I could sure use a drink right now.</ion-view>'
})
});
<!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="partial-home.html">
<ion-view view-title="def" hide-nav-bar="false" class="padding padding-vertical">
<ion-nav-buttons side="right">
<button class="button button-icon ion-home"></button>
<button class="button button-icon ion-ios-email"></button>
<button class="button button-icon ion-ios-person"></button>
</ion-nav-buttons>
<ion-tabs class="tabs-icon-top">
<ion-tab title="list" icon="icon ion-home" href="#/home/list">
<ion-nav-view name="list"></ion-nav-view>
</ion-tab>
<ion-tab title="paragraph" icon="icon ion-heart" href="#/home/paragraph">
<ion-nav-view name="paragraph"></ion-nav-view>
</ion-tab>
</ion-tabs>
</ion-view>
</script>
<script type="text/ng-template" id="partial-home-list.html">
<ion-view view-title="list">
<ul>
<li ng-repeat="dog in dogs">{{ dog }}</li>
</ul>
</ion-view>
</script>

<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>
</ion-nav-bar>
<ion-nav-view>
</ion-nav-view>
</body>
</html>
它呈现以下输出:- enter image description here

以下是我面临的问题:-1) 虽然出现了选项卡,但是当我单击单个选项卡时,它的内部内容没有填充当前代码(我已经发布)并且导航栏标题也没有改变,尽管在中设置了 view-title 属性每个子状态模板。

2) 在 html 代码的 partial-home.html 模板中,我希望导航栏中有一些额外的按钮,但这些按钮也没有显示。

3) 但是,当我将 partial-home.html 更改为下面给出的内容时(我已经从 ion-nav-view 中删除了名称属性),

<script type="text/ng-template" id="partial-home.html">
<ion-view view-title="def" hide-nav-bar="false" class="padding padding-vertical">
<ion-nav-buttons side="right">
<button class="button button-icon ion-home"></button>
<button class="button button-icon ion-ios-email"></button>
<button class="button button-icon ion-ios-person"></button>
</ion-nav-buttons>
<ion-tabs class="tabs-icon-top">
<ion-tab title="list" icon="icon ion-home" href="#/home/list">
<ion-nav-view></ion-nav-view>
</ion-tab>
<ion-tab title="paragraph" icon="icon ion-heart" href="#/home/paragraph">
<ion-nav-view></ion-nav-view>
</ion-tab>
</ion-tabs>
</ion-view>
</script>

然后,当我单击单个选项卡时,选项卡内容正确显示,但选项卡内容出现在导航栏后面,如下图所示:- enter image description here

我不知道,我哪里错了。提前致谢。

最佳答案

  1. 不要使用 script标签创建不同的标签页。我建议您下载 starter tabs 模板并研究一下

Ionic start appname tabs

  1. navbar纽扣将此代码包含在您想要按钮的页面中。

`

<ion-nav-buttons side="right">
<button class="button" ng-click="doSomething()">doSomething</button>
</ion-nav-buttons>

The side to place the buttons in the ionNavBar. Available sides: primary, secondary, left, and right.

  1. 如果内容位于导航栏后面,请将其写入 <ion-content>

<ion-content has-header="true">

关于html - 为什么 ionic 标签没有正确呈现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42757262/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com