pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<small id='RSdmD'></small><noframes id='RSdmD'>

    <tfoot id='RSdmD'></tfoot>
        <bdo id='RSdmD'></bdo><ul id='RSdmD'></ul>

        <i id='RSdmD'><tr id='RSdmD'><dt id='RSdmD'><q id='RSdmD'><span id='RSdmD'><b id='RSdmD'><form id='RSdmD'><ins id='RSdmD'></ins><ul id='RSdmD'></ul><sub id='RSdmD'></sub></form><legend id='RSdmD'></legend><bdo id='RSdmD'><pre id='RSdmD'><center id='RSdmD'></center></pre></bdo></b><th id='RSdmD'></th></span></q></dt></tr></i><div class="zxtbjhf" id='RSdmD'><tfoot id='RSdmD'></tfoot><dl id='RSdmD'><fieldset id='RSdmD'></fieldset></dl></div>
        <legend id='RSdmD'><style id='RSdmD'><dir id='RSdmD'><q id='RSdmD'></q></dir></style></legend>

      1. 如何使用 ionic2 框架創建或自定義 Toast 視圖

        How to create or customize a Toast view using ionic2 framework(如何使用 ionic2 框架創建或自定義 Toast 視圖)

          <tbody id='47JoK'></tbody>
          <bdo id='47JoK'></bdo><ul id='47JoK'></ul>
          <i id='47JoK'><tr id='47JoK'><dt id='47JoK'><q id='47JoK'><span id='47JoK'><b id='47JoK'><form id='47JoK'><ins id='47JoK'></ins><ul id='47JoK'></ul><sub id='47JoK'></sub></form><legend id='47JoK'></legend><bdo id='47JoK'><pre id='47JoK'><center id='47JoK'></center></pre></bdo></b><th id='47JoK'></th></span></q></dt></tr></i><div class="xpp7r5j" id='47JoK'><tfoot id='47JoK'></tfoot><dl id='47JoK'><fieldset id='47JoK'></fieldset></dl></div>

              <legend id='47JoK'><style id='47JoK'><dir id='47JoK'><q id='47JoK'></q></dir></style></legend>
              <tfoot id='47JoK'></tfoot>

              1. <small id='47JoK'></small><noframes id='47JoK'>

                • 本文介紹了如何使用 ionic2 框架創建或自定義 Toast 視圖的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我是 ionic2 開發的新手.嘗試向用戶顯示 toast 消息,但是使用 ionic2 框架只能在 toast 視圖中顯示字符串消息,我想以自定義視圖的形式顯示圖像和一些其他字符串.我該怎么做.

                  我從 ionic 網站獲得了這個鏈接,上面說我們可以顯示字符串.

                  這個想法是使用 Ionic2 的 ModalController,但使用 ugly 和小的解決方法來修改該模式的樣式,而不影響應用程序的其他模式.

                  當頁面顯示時(即使它被用作模式頁面),組件的名稱用于在 html 代碼中的 元素中設置一個類.我們將使用該類來設置模態框的樣式,使其看起來像 Toast,但要利用頁面來顯示其內容,以便我們可以放置圖像和其他一些東西.

                  對于這個演示,我創建了一個帶有兩個按鈕的頁面:

                  <ion-header><離子導航欄><ion-title>ModalController 演示</ion-title></離子導航欄></離子頭><離子含量填充><h5>具有自定義大小的模態控制器</h5><button(click)="presentCustomModal()">打開自定義Modal</button><button(click)="presentDefaultModal()">打開默認模態</button></離子含量>

                  并使用以下代碼:

                  從'@angular/core'導入{組件};導入 { NavController, ModalController, ViewController } from 'ionic-angular';@零件({templateUrl: 'build/pages/modal-controller-custom-size/modal-controller-custom-size.html',})導出類 ModalControllerCustomSizePage {構造函數(私有 navCtrl:NavController,私有 modalCtrl:ModalController){}presentCustomModal() {讓 customModal = this.modalCtrl.create(CustomModalPage);customModal.onDidDismiss(() => {//做你想做的...});//呈現模態customModal.present();}presentDefaultModal() {讓 defaultModal = this.modalCtrl.create(DefaultModalPage);defaultModal.onDidDismiss(() => {//做你想做的...});//呈現模態defaultModal.present();}}/* ********************自定義模態************************ */@零件({模板:'<離子頭>'+'<ion-navbar dark>'+'<ion-title>我的自定義模態</ion-title>'+'<離子按鈕結束>'+'<button (click)="dismiss()">關閉</button>'+'</離子按鈕>'+'</離子導航欄>'+'</離子頭>'+'<離子含量填充>'+'<離子網格>'+'<離子行>'+'<ion-col width-50><img src="http://placehold.it/150x150"/></ion-col>'+'<ion-col width-50>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</ion-col>'+'</離子行>'+'</離子網格>'+'</離子含量>',})類 CustomModalPage {構造函數(公共 viewCtrl:ViewController){}公開解雇(){this.viewCtrl.dismiss();}}/* ********************默認模態************************ */@零件({模板:'<離子頭>'+'<離子導航欄>'+'<ion-title>默認模式</ion-title>'+'<離子按鈕結束>'+'<button (click)="dismiss()">關閉</button>'+'</離子按鈕>'+'</離子導航欄>'+'</離子頭>'+'<離子含量填充>'+'<h5>模態內容...</h5>'+'</離子含量>',})類 DefaultModalPage {構造函數(公共 viewCtrl:ViewController){}公開解雇(){this.viewCtrl.dismiss();}}

                  請注意,我在同一頁面中包含了將用作模式的兩個組件的代碼,只是為了使代碼更易于閱讀.推薦的方法是將每個 Component 放在自己的 .ts 文件中.

                  到目前為止,該代碼沒有什么特別之處,只是一個打開兩個不同(但整頁)模式的頁面.魔術將通過使用這些樣式規則來完成:

                  .custom-modal-page {高度:270px;位置:絕對;頂部:計算(100% - 270px);離子含量{背景顏色:#333;顏色:#eee;}}

                  由于我們使用的是 .custom-modal-page 類,因此這些更改只會影響自定義模式,而不影響默認模式.

                  I am new to ionic2 development. Trying to show a toast message to the user, However using ionic2 framework am able to display only string message's in the toast view, I want to display a image and few other string in the form of customized view. How can i do that.

                  I got this link from ionic site which says we can display string's. http://ionicframework.com/docs/v2/api/components/toast/ToastController/

                  Any suggestions ?

                  解決方案

                  I've been playing around with this, and I think I found a workaround, but please notice that this is just that, a workaround, and may cause some other things to break somehow.

                  The final result is something like this:

                  The idea is to use Ionic2's ModalController but using an ugly and small workaround to modify the styles of that modal without affecting other modals of the app.

                  When a page is shown (even though if it's used as a modal page) the Component's name is used to set a class in the <ion-page> element in the html code. We're going to use that class to style a modal to make it look like a Toast, but taking advantage of using a page for it's content so we can put an image and some other things.

                  For this demo, I've created a page with two buttons:

                  <ion-header>
                  
                    <ion-navbar>
                      <ion-title>ModalController Demo</ion-title>
                    </ion-navbar>
                  
                  </ion-header>
                  
                  <ion-content padding>
                      <h5>ModalController with custom size</h5>
                  
                      <button (click)="presentCustomModal()">Open Custom Modal</button>
                  
                      <button (click)="presentDefaultModal()">Open Default Modal</button>
                  
                  </ion-content>
                  

                  And with the following code:

                  import { Component } from '@angular/core';
                  import { NavController, ModalController, ViewController } from 'ionic-angular';
                  
                  @Component({
                      templateUrl: 'build/pages/modal-controller-custom-size/modal-controller-custom-size.html',
                  })
                  export class ModalControllerCustomSizePage {
                  
                      constructor(private navCtrl: NavController, private modalCtrl: ModalController) {
                  
                      }
                  
                      presentCustomModal() {
                          let customModal = this.modalCtrl.create(CustomModalPage);
                  
                          customModal.onDidDismiss(() => {
                              // Do what you want ...
                          });
                  
                          // Present the modal
                          customModal.present();
                      }
                  
                      presentDefaultModal() {
                          let defaultModal = this.modalCtrl.create(DefaultModalPage);
                  
                          defaultModal.onDidDismiss(() => {
                              // Do what you want ...
                          });
                  
                          // Present the modal
                          defaultModal.present();
                      }
                  
                  }
                  
                  /* ********************
                      Custom modal 
                  ********************* */
                  @Component({
                      template:   '<ion-header>' +
                                      '<ion-navbar dark>' +
                                          '<ion-title>My custom modal</ion-title>' +
                                          '<ion-buttons end>' +
                                              '<button (click)="dismiss()">Close</button>' +
                                          '</ion-buttons>' +
                                      '</ion-navbar>' +
                                  '</ion-header>' +
                                  '<ion-content padding>' +
                                      '<ion-grid>' +
                                          '<ion-row>' +
                                              '<ion-col width-50><img src="http://placehold.it/150x150"/></ion-col>' +
                                              '<ion-col width-50>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</ion-col>' +
                                          '</ion-row>' +
                                      '</ion-grid>' +
                                  '</ion-content>',
                  })
                  class CustomModalPage {
                  
                      constructor(public viewCtrl: ViewController) {
                  
                      }
                  
                      public dismiss() {
                          this.viewCtrl.dismiss();
                      }
                  }
                  
                  /* ********************
                      Default modal 
                  ********************* */
                  @Component({
                      template:   '<ion-header>' +
                                      '<ion-navbar>' +
                                          '<ion-title>Default modal</ion-title>' +
                                          '<ion-buttons end>' +
                                              '<button (click)="dismiss()">Close</button>' +
                                          '</ion-buttons>' +
                                      '</ion-navbar>' +
                                  '</ion-header>' +
                                  '<ion-content padding>' +
                                      '<h5>Modal content...</h5>' +
                                  '</ion-content>',
                  })
                  class DefaultModalPage {
                  
                      constructor(public viewCtrl: ViewController) {
                  
                      }
                  
                      public dismiss() {
                          this.viewCtrl.dismiss();
                      }
                  }
                  

                  Please notice that I included the code of the two components that are going to be used as modals in the same page, just to make the code easier to read. The recommended approach is to put every Component in its own .ts file.

                  Until now there's nothing special in that code, is just a page that opens two different (but full-page) modals. The magic will be done by using these style rules:

                  .custom-modal-page {
                      height: 270px;
                      position: absolute;
                      top: calc(100% - 270px);
                  
                      ion-content {
                          background-color: #333;
                          color: #eee;
                      }
                  }
                  

                  Since we're using the .custom-modal-page class, those changes will only affect the custom modal and not the default one.

                  這篇關于如何使用 ionic2 框架創建或自定義 Toast 視圖的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數據更新 Observable)
                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態元素 - Angular 2 amp;離子2)

                  <small id='2lfjU'></small><noframes id='2lfjU'>

                      <legend id='2lfjU'><style id='2lfjU'><dir id='2lfjU'><q id='2lfjU'></q></dir></style></legend>

                          <bdo id='2lfjU'></bdo><ul id='2lfjU'></ul>
                          <i id='2lfjU'><tr id='2lfjU'><dt id='2lfjU'><q id='2lfjU'><span id='2lfjU'><b id='2lfjU'><form id='2lfjU'><ins id='2lfjU'></ins><ul id='2lfjU'></ul><sub id='2lfjU'></sub></form><legend id='2lfjU'></legend><bdo id='2lfjU'><pre id='2lfjU'><center id='2lfjU'></center></pre></bdo></b><th id='2lfjU'></th></span></q></dt></tr></i><div class="r7hxrrx" id='2lfjU'><tfoot id='2lfjU'></tfoot><dl id='2lfjU'><fieldset id='2lfjU'></fieldset></dl></div>
                            <tbody id='2lfjU'></tbody>
                          <tfoot id='2lfjU'></tfoot>

                          1. 主站蜘蛛池模板: 新能源汽车电机定转子合装机 - 电机维修设备 - 睿望达 | 优秀的临床医学知识库,临床知识库,医疗知识库,满足电子病历四级要求,免费试用 | 哔咔漫画网页版在线_下载入口访问指引| CPSE安博会| BHK汞灯-百科|上海熙浩实业有限公司 | 粘度计NDJ-5S,粘度计NDJ-8S,越平水分测定仪-上海右一仪器有限公司 | 工业用品一站式采购平台|南创工品汇-官网|广州南创 | 恒温恒湿箱(药品/保健品/食品/半导体/细菌)-兰贝石(北京)科技有限公司 | 污水处理设备维修_污水处理工程改造_机械格栅_过滤设备_气浮设备_刮吸泥机_污泥浓缩罐_污水处理设备_污水处理工程-北京龙泉新禹科技有限公司 | 东莞市天进机械有限公司-钉箱机-粘箱机-糊箱机-打钉机认准东莞天进机械-厂家直供更放心! | 杭州月嫂技术培训服务公司-催乳师培训中心报名费用-产后康复师培训机构-杭州优贝姆健康管理有限公司 | 广西绿桂涂料--承接隔热涂料、隔音涂料、真石漆、多彩仿石漆等涂料工程双包施工 | 酵素生产厂家_酵素OEM_酵素加盟_酵素ODM_酵素原料厂家_厦门益力康 | 自动钻孔机-全自动数控钻孔机生产厂家-多米(广东)智能装备有限公司 | 青岛侦探调查_青岛侦探事务所_青岛调查事务所_青岛婚外情取证-青岛狄仁杰国际侦探公司 | 清水-铝合金-建筑模板厂家-木模板价格-铝模板生产「五棵松」品牌 | 单螺旋速冻机-双螺旋-流态化-隧道式-食品速冻机厂家-广州冰泉制冷 | 磨煤机配件-高铬辊套-高铬衬板-立磨辊套-盐山县宏润电力设备有限公司 | 磨煤机配件-高铬辊套-高铬衬板-立磨辊套-盐山县宏润电力设备有限公司 | 求是网 - 思想建党 理论强党| 一体化隔油提升设备-餐饮油水分离器-餐厨垃圾处理设备-隔油池-盐城金球环保产业发展有限公司 | 户外-组合-幼儿园-不锈钢-儿童-滑滑梯-床-玩具-淘气堡-厂家-价格 | 金环宇|金环宇电线|金环宇电缆|金环宇电线电缆|深圳市金环宇电线电缆有限公司|金环宇电缆集团 | FFU_空气初效|中效|高效过滤器_空调过滤网-广州梓净净化设备有限公司 | 常州律师事务所_常州律所_常州律师-江苏乐天律师事务所 | 超声波电磁流量计-液位计-孔板流量计-料位计-江苏信仪自动化仪表有限公司 | 瓶盖扭矩测试仪-瓶盖扭力仪-全自动扭矩仪-济南三泉中石单品站 | 上海办公室装修,办公楼装修设计,办公空间设计,企业展厅设计_写艺装饰公司 | 磁棒电感生产厂家-电感器厂家-电感定制-贴片功率电感供应商-棒形电感生产厂家-苏州谷景电子有限公司 | 浩方智通 - 防关联浏览器 - 跨境电商浏览器 - 云雀浏览器 | 网站建设-网站制作-网站设计-网站开发定制公司-网站SEO优化推广-咏熠软件 | 新型锤式破碎机_新型圆锥式_新型颚式破碎机_反击式打沙机_锤式制砂机_青州建源机械 | 警用|治安|保安|不锈钢岗亭-售货亭价格-垃圾分类亭-移动厕所厂家-苏州灿宇建材 | 插针变压器-家用电器变压器-工业空调变压器-CD型电抗器-余姚市中驰电器有限公司 | 济南铝方通-济南铝方通价格-济南方通厂家-山东鲁方通建材有限公司 | 电竞学校_电子竞技培训学校学院-梦竞未来电竞学校官网 | 悬浮拼装地板_幼儿园_篮球场_悬浮拼接地板-山东悬浮拼装地板厂家 | 过滤器_自清洗过滤器_气体过滤器_苏州华凯过滤技术有限公司 | 郑州宣传片拍摄-TVC广告片拍摄-微电影短视频制作-河南优柿文化传媒有限公司 | 润滑油加盟_润滑油厂家_润滑油品牌-深圳市沃丹润滑科技有限公司 琉璃瓦-琉璃瓦厂家-安徽盛阳新型建材科技有限公司 | 医院专用门厂家报价-医用病房门尺寸大全-抗菌木门品牌推荐 |