Ionic2學(xué)習(xí)基礎(chǔ)之Toast和Grid
Ionic2 组件之Toast
demo
demo
和Alert组件类似,都是为了提示信息给用户看的,不过使用Toast不会像Alert那样会显示遮罩层。
Options| Property | Type | Default | Description |
|---|---|---|---|
| message | string | -- | 显示的信息 |
| duration | number | -- | 提示框持续的时间,如果不设置则持续到dismiss()事件被调用 |
| position | string | 'bottom' | 提示框出现的位置,可选的有:top,middle,bottom |
| showCloseButton | boolean | false | 是否显示关闭按钮 |
| closeButtonText | string | 'Close' | 关闭按钮上显示的文本 |
| dismissOnPageChange | boolean | false | 切换页面时是否关闭提示框 |
| cssClass | string | -- | 额外的样式 |
使用方式如下:
presentToast(){
let toast = this.toastCtrl.create({
message:'this is a toast',
duration:3000,
position:"bottom",
showCloseButton:true,
closeButtonText:'x',
cssClass:'danger',
dismissOnPageChange:true
});
toast.present();
}
Ionic2 组件之Grid
和现在html流行的自适应栅格布局类似,Ionic也是采用了grid来进行布局
简单的用法如下:
<ion-grid>
<ion-row>
<ion-col width-10>This column will take 10% of space</ion-col>
</ion-row>
</ion-grid>
可以看到和bootstrap非常类似,因此offset肯定也是有的了
栅格大小| Property | width(百分比) |
|---|---|
| width-10 | 10% |
| width-20 | 25% |
| width-33 | 33.3333% |
| width-50 | 50% |
| width-67 | 66.6666% |
| width-75 | 75% |
| width-80 | 80% |
| width-90 | 90% |
<ion-grid>
<ion-row>
<ion-col width-10>width-10</ion-col>
<ion-col width-20>width-20</ion-col>
<ion-col width-50>width-50</ion-col>
</ion-row>
<ion-row>
<ion-col width-33>width-33</ion-col>
<ion-col width-33>width-33</ion-col>
<ion-col width-33>width-33</ion-col>
</ion-row>
<ion-row>
<ion-col width-20 offset-33 center>width-33</ion-col>
</ion-row>
<ion-row wrap>aaa</ion-row>
<ion-row wrap>aaa</ion-row>
<ion-row wrap>aaa</ion-row>
<ion-row center>
<ion-col width-33>width-33</ion-col>
<ion-col width-33 >aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</ion-col>
</ion-row>
<ion-row baseline>
<ion-col width-33>width-33</ion-col>
<ion-col width-33 >bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb</ion-col>
</ion-row>
</ion-grid>
點(diǎn)擊查看更多內(nèi)容
3人點(diǎn)贊
評(píng)論
評(píng)論
共同學(xué)習(xí),寫(xiě)下你的評(píng)論
評(píng)論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開(kāi)微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得
100積分直接送
付費(fèi)專(zhuān)欄免費(fèi)學(xué)
大額優(yōu)惠券免費(fèi)領(lǐng)