-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOM基础测试47期 #75
Comments
document.addEventListener( "visibilitychange", function(){
if( !document.hidden ){
getAccount();
}
}) |
document.addEventListener('visibilitychange', () => {
if (!document.hidden) { // 页面由隐藏变为显示时
getAccount()
}
})
window.addEventListener('load', getAccount) // 页面第一次加载 |
document.addEventListener( "visibilitychange", function(){ // 可视态切换
if( document.visibilityState === 'visible'){
getAccount();
}
})
getAccout() // 首次进入页面 |
document.addEventListener("visibilitychange", function() {
var state = document.visibilityState
if(state==='visible'){getAccount()}
});
getAccount() |
window.addEventListener('focus', () => {
getAccount()
}) |
看了大家的回答才知道 。 |
"visibilitychange" 和 直接执行。参考 @liyongleihf2006 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
账户页有一个刷新账户余额的方法,假设名为getAccount();
请实现,无论从哪个页面哪种形式回到账户页(例如:切换浏览器选项卡或者APP的webview返回),或者首次进入账户页,都执行一次getAccount()方法。
本题考点在于如何判断当前页面进入可视态或者激活态。大家提交回答的时候,注意缩进距离,起始位置从左边缘开始;另外,github自带代码高亮,所以请使用下面示意的格式。
其他
本期小测没有直播,也没有打分,但是会反馈要点。
The text was updated successfully, but these errors were encountered: