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. 主站蜘蛛池模板: 电池高低温试验箱-气态冲击箱-双层电池防爆箱|简户百科 | 行吊_电动单梁起重机_双梁起重机_合肥起重机_厂家_合肥市神雕起重机械有限公司 | 艾乐贝拉细胞研究中心 | 国家组织工程种子细胞库华南分库 | 西安中国国际旅行社(西安国旅) | 济南保安公司加盟挂靠-亮剑国际安保服务集团总部-山东保安公司|济南保安培训学校 | 百度爱采购运营研究社社群-店铺托管-爱采购代运营-良言多米网络公司 | 扬尘监测_扬尘监测系统_带证扬尘监测设备 - 郑州港迪科技有限公司 | 气象监测系统_气象传感器_微型气象仪_气象环境监测仪-山东风途物联网 | 进口消泡剂-道康宁消泡剂-陶氏消泡剂-大洋消泡剂 | Eiafans.com_环评爱好者 环评网|环评论坛|环评报告公示网|竣工环保验收公示网|环保验收报告公示网|环保自主验收公示|环评公示网|环保公示网|注册环评工程师|环境影响评价|环评师|规划环评|环评报告|环评考试网|环评论坛 - Powered by Discuz! | LZ-373测厚仪-华瑞VOC气体检测仪-个人有毒气体检测仪-厂家-深圳市深博瑞仪器仪表有限公司 | 捷码低代码平台 - 3D数字孪生_大数据可视化开发平台「免费体验」 | 玻璃钢板-玻璃钢防腐瓦-玻璃钢材料-广东壹诺 | 派克防爆伺服电机品牌|国产防爆伺服电机|高低温伺服电机|杭州摩森机电科技有限公司 | 便携式谷丙转氨酶检测仪|华图生物科技百科 | 斗式提升机,斗式提升机厂家-淄博宏建机械有限公司 | 电动球阀_不锈钢电动球阀_电动三通球阀_电动调节球阀_上海湖泉阀门有限公司 | 招商帮-一站式网络营销服务|互联网整合营销|网络推广代运营|信息流推广|招商帮企业招商好帮手|搜索营销推广|短视视频营销推广 | 河北中仪伟创试验仪器有限公司是专业生产沥青,土工,水泥,混凝土等试验仪器的厂家,咨询电话:13373070969 | 合肥弱电工程_安徽安防工程_智能化工程公司-合肥雷润 | 软文推广发布平台_新闻稿件自助发布_媒体邀约-澜媒宝 | 双段式高压鼓风机-雕刻机用真空泵-绍兴天晨机械有限公司 | 鑫铭东办公家具一站式定制采购-深圳办公家具厂家直销 | 多米诺-多米诺世界纪录团队-多米诺世界-多米诺团队培训-多米诺公关活动-多米诺创意广告-多米诺大型表演-多米诺专业赛事 | 高硼硅玻璃|水位计玻璃板|光学三棱镜-邯郸奥维玻璃科技有限公司 高温高压釜(氢化反应釜)百科 | 磁力抛光机_磁力研磨机_磁力去毛刺机_精密五金零件抛光设备厂家-冠古科技 | 油漆辅料厂家_阴阳脚线_艺术漆厂家_内外墙涂料施工_乳胶漆专用防霉腻子粉_轻质粉刷石膏-魔法涂涂 | 手板_手板模型制作_cnc手板加工厂-东莞天泓 | 河南15年专业网站建设制作设计,做网站就找郑州启凡网络公司 | 热镀锌槽钢|角钢|工字钢|圆钢|H型钢|扁钢|花纹板-天津千百顺钢铁贸易有限公司 | 全自动面膜机_面膜折叠机价格_面膜灌装机定制_高速折棉机厂家-深圳市益豪科技有限公司 | 超声波成孔成槽质量检测仪-压浆机-桥梁预应力智能张拉设备-上海硕冠检测设备有限公司 | 河南卓美创业科技有限公司-河南卓美防雷公司-防雷接地-防雷工程-重庆避雷针-避雷器-防雷检测-避雷带-避雷针-避雷塔、机房防雷、古建筑防雷等-山西防雷公司 | 哈尔滨治「失眠/抑郁/焦虑症/精神心理」专科医院排行榜-京科脑康免费咨询 一对一诊疗 | 冷热冲击试验箱_温度冲击试验箱价格_冷热冲击箱排名_林频厂家 | 中国产业发展研究网 - 提供行业研究报告 可行性研究报告 投资咨询 市场调研服务 | 行吊_电动单梁起重机_双梁起重机_合肥起重机_厂家_合肥市神雕起重机械有限公司 | 全自动固相萃取仪_高通量真空平行浓缩仪-勤业永为 | 大流量卧式砂磨机_强力分散机_双行星双动力混合机_同心双轴搅拌机-莱州市龙跃化工机械有限公司 | 合肥升降机-合肥升降货梯-安徽升降平台「厂家直销」-安徽鼎升自动化科技有限公司 | 加热制冷恒温循环器-加热制冷循环油浴-杭州庚雨仪器有限公司 |