ionic 删除返回按钮文字,及自定义nav两侧的按钮和title格式

1、删除返回按钮文字

1)可以在app.js进行配置

.config(function($stateProvider, $urlRouterProvider,$ionicConfigProvider) {

      $ionicConfigProvider.platform.ios.tabs.style('standard');
      $ionicConfigProvider.platform.ios.tabs.position('bottom');
      $ionicConfigProvider.platform.android.tabs.style('standard');
      $ionicConfigProvider.platform.android.tabs.position('standard');

      $ionicConfigProvider.platform.ios.navBar.alignTitle('center');
      $ionicConfigProvider.platform.android.navBar.alignTitle('center');

      $ionicConfigProvider.platform.ios.backButton.previousTitleText('').icon('ion-android-arrow-back');
      $ionicConfigProvider.platform.android.backButton.previousTitleText('').icon('ion-ios-arrow-back');

2)如果上面行不通,那么就去改源码 如下所示

打开lib下的ionic.bundle.js

注释掉下面这句代码:

// buttonEle.appendChild(buttonTextEle);
    function hasIconClass(ele) {
        return /ion-|icon/.test(ele.className);
      }

      var defaultIcon = $ionicConfig.backButton.icon();
      if (!hasIcon && defaultIcon && defaultIcon !== 'none') {
        buttonEle.innerHTML = '<i class="icon ' + defaultIcon + '"></i> ' + buttonEle.innerHTML;
        buttonEle.className += ' button-clear';
      }

      if (!hasInnerText) {
        var buttonTextEle = $document[0].createElement('span');
        buttonTextEle.className = 'back-text';

        if (!hasButtonText && $ionicConfig.backButton.text()) {
          buttonTextEle.innerHTML += '<span class="default-title">' + $ionicConfig.backButton.text() + '</span>';
        }
        if (!hasPreviousTitle && $ionicConfig.backButton.previousTitleText()) {
          buttonTextEle.innerHTML += '<span class="previous-title"></span>';
        }
        // buttonEle.appendChild(buttonTextEle);

      }

 

2、隐藏默认返回按钮

在ion-view标签加上 hide-back-button="true" 即可;

 

3、自定义Nav两侧的button及Nav的title

1)两侧按钮

//nav左边功能按钮
<ion-nav-buttons side="left">
      <button class="button button-clear">
        <i class="icon ion-ios-chatbubble-outline"></i>
      </button>
</ion-nav-buttons>
//nav右边功能按钮
<ion-nav-buttons side="right">
      <button class="button button-clear">
        <i class="icon ion-ios-chatbubble-outline"></i>
      </button>
</ion-nav-buttons>

2)Nav的title

//ion-nav-title 标签里面的内容随便改
 <ion-nav-title>
      <h1 class="title"> 购物车</h1>
 </ion-nav-title>

 

posted @ 2017-05-30 00:24  FEer_llx  阅读(2641)  评论(0编辑  收藏  举报