2017-01-19 68 views
0

有一個選項,使用離子1中的動作表的html標記。
如何使用帶有離子2動作表的html標籤?

我在離子2中試過​​相同但沒用。

以下是我的代碼。

let actionSheet = this.actionSheetCtrl.create({ 
       title: '<b>Choose</b>', 
       buttons: [ 
        {}....... 

人這樣做呢?

具體地說我想在動作片

+0

你是想讓它變成粗體還是它是一個隨機的例子? –

+0

不僅大膽嘗試使用html標籤,但不工作,我剛剛給出樣品 –

+0

我不認爲有一個規定htm。但[在這裏檢查](https://ionicframework.com/docs/v2/api/components/action-sheet/ActionSheetController/)你可以設置cssClass選項來定製,如果這是你的要求。 –

回答

1

號。標題不允許一個HTML字符串添加的圖像,也沒有任何其它屬性允許HTML字符串。

最好的辦法是在動作片添加cssClass

let actionSheet = this.actionSheetCtrl.create({ 
      cssClass: 'title-img', 

這將讓您和您使用的任何其他動作片區分清楚地描述了CSS的可維護性。

然後,你可以偷偷摸摸的與CSS。所以在動作片的主標題類是.action-sheet-title

因此,爲了添加圖像標題旁邊的,你只需要與::before::after

的後綴選擇例如

.title-img .action-sheet-title::before{ // if you want the image on the left of the title 
    background:url('path-to-image-here') no-repeat; 
    height: 50px; 
    width: 50px; 
} 

這應該工作。