ionic 3 常用集-持续更新

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013022210/article/details/80089800

1.隐藏返回键

<ion-header>
  <ion-navbar [hideBackButton]="true">
    <ion-buttons start>
      <button ion-button icon-only color="light">
        取消
      </button>
    </ion-buttons>
    <ion-title>{{navParams.data.title}}</ion-title>
    <ion-buttons end>
      <button ion-button icon-only color="light" >
        编辑
      </button>
    </ion-buttons>
  </ion-navbar>
</ion-header>

2.ionic2/3 页面默认滚动到底部两种方法:

方法1体验不是很好,200毫秒的延迟视觉上可以看出来

方法2异步的请求有时候不能及时响应(可以请求第一次后存入本地存储里面),经过测试 虽然ionic3 中本地存储也是异步的,但是毫无延迟(可能是比较快)

推荐1+2一起使用

1.使用 content 组件的 scrollToBottom() 方法,可以封装成函数使用:

//页面滚动到底部  
scrollToBottom() {
  setTimeout(() => {
    if(this.content.scrollToBottom){
      this.content.scrollToBottom(0);
    }
  },200)
}

2..使用 content 组件的 scrollDownOnLoad 属性:

<ion-content scrollDownOnLoad="true"></ion-content>



猜你喜欢

转载自blog.csdn.net/u013022210/article/details/80089800