2017-08-14 151 views
2

這是我的代碼,我試過text-wrap,裏面的ion-header仍然不能顯示整個標題。離子 - 如何在離子標題中纏繞長字符串

<ion-header> 
    <ion-toolbar text-wrap color="danger"> 
    <ion-buttons> 
     <button ion-button navPop icon-only> 
      <ion-icon ios="ios-arrow-back" md="md-arrow-back"></ion-icon> 
     </button> 
    </ion-buttons> 
    <ion-title>{{new.title}}</ion-title> 
    </ion-toolbar> 
</ion-header> 

enter image description here

更新

<ion-header> 
    <ion-toolbar color="danger"> 
    <ion-buttons> 
     <button ion-button navPop icon-only> 
      <ion-icon ios="ios-arrow-back" md="md-arrow-back"></ion-icon> 
     </button> 
    </ion-buttons> 
    <ion-item color="danger" text-wrap> 
    <ion-title >{{new.title}}</ion-title> 
    </ion-item> 
    </ion-toolbar> 
</ion-header> 

我嘗試添加ion-item存在,但仍然沒有爲我工作。 enter image description here

更新2

.ios .toolbar-title { 
    text-overflow: inherit; 
    white-space: normal; 
    text-align: left; 
    font-size:1.3em; 
} 

.md .toolbar-title { 
    text-overflow: inherit; 
    white-space: normal; 
    text-align: left; 
    font-size:1.3em; 
} 

enter image description here

+0

包括這麼長的標題似乎是一個不好的設計......你爲什麼不包括那個長頭銜作爲一個頭銜,但是在page_的_body中呢? – sebaferreras

+1

這一個爲某人工作,不是由我自己設計。謝謝:) –

+1

@sebaferreras你爲什麼認爲這是糟糕的設計?我只需要在頁面上處理這個問題,在那裏我會顯示聯繫人的詳細信息。標題有聯繫人的全名,有些人的名字很長。將聯繫人全名作爲頁面標題是否是一個糟糕的設計? –

回答

5

PLS更新如下CSS文件:

.toolbar-title { 
    text-overflow: inherit; 
    white-space: normal; 
} 

編輯:

或者

.toolbar-title { 
    text-overflow: unset; 
    white-space: unset; 
} 
+1

非常感謝你!!!這個爲我工作! –

+0

謝謝..但爲什麼ios顯示不好我的應用程序..我更新新代碼和圖像在我的問題 –

+0

不知道爲什麼ios與android @Mankeomorakort不同 –

0

試試這個代碼

<ion-header> 
    <ion-navbar color="danger"> 

    <button (tap)="Back()" ion-button menuToggle> 
     <ion-icon ios="ios-arrow-back" md="md-arrow-back"></ion-icon> 
    </button> 

    <ion-title>asdfasfasdf</ion-title> 

    </ion-navbar> 
</ion-header> 

在你pagecomponent

Back(){ 
    this.navCtrl.pop(); 
}