Ionic 以编程方式显示离子刷新器 [英] Ionic show ion-refresher programmatically

查看:9
本文介绍了Ionic 以编程方式显示离子刷新器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以编程方式显示离子清新剂.例如,在第一页加载时,我加载数据并希望显示离子刷新器.我没有发现任何内置函数只有_beginRefresh.此函数将触发刷新器,但它不会在刷新器元素上设置样式属性 TOP.因此它隐藏在 NAV 后面.

i want to display the ion-refresher programmatically. e.g on the first page load i load the data and want to show the ion-refresher. i've not found any build in function only _beginRefresh. this function will fire the refresher, however it will not set the style attribute TOP on the refresher element. therefore it is hidden behind the NAV.

目前我已经创建了一个肮脏的解决方法.

currently i've created a dirty workaround.

let scrollcontent = document.getElementsByClassName('ion-page')[0].getElementsByTagName('ion-content')[0].getElementsByClassName('scroll-content')[0]
let rect = scrollcontent.getBoundingClientRect()
document.getElementById('refresher').style.top = rect.top.toString() + 'px'
this.myRefresher._beginRefresh()

我想知道是否有更好的方法.谢谢

i'm wondering if there is a better aproach. thanks

推荐答案

好的,我找到了更好的方法...

ok i've found a better approach...

@ViewChild(Content) ContentDashboard: Content;
this.RefresherDashboard._top = this.ContentDashboard.contentTop.toString() + 'px'
this.RefresherDashboard._beginRefresh()

这篇关于Ionic 以编程方式显示离子刷新器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆