简体   繁体   English

页面加载 div 有时加载无穷无尽

[英]Page loading div loads endless sometimes

My pre page load script sometimes bugs out and is “loading” endless.我的页面前加载脚本有时会出错,并且会无休止地“加载”。

No console logs.没有控制台日志。 Page is loaded correctly under the cover div.页面在封面 div 下正确加载。

It's hard to explain any logic to moment it happens, looks like random thing.很难在它发生的那一刻解释任何逻辑,看起来像是随机的事情。

custom.js:自定义.js:

$(function() {
    $(window).on("load", function(){
        $('#loader').css("display", "none", function() {
          $(this).remove();
        });
        $('html, body').css({
            'overflow': 'auto',
        })
    })
});

header.php: header.php:

<body <?php body_class('d-flex flex-column h-100 no-scroll');?>>

<div id="loader"><p>Loading</p></div>
    <?php wp_body_open(); ?>

    <header class="site-header”>

[...]

I'm using Wordpress.我正在使用 Wordpress。

You can remove the onLoad listener from your function. That might be a problem due to variaous reasons.您可以从 function 中删除 onLoad 侦听器。由于各种原因,这可能是个问题。 Can you try:你能试一下吗:

$(window).on("load", function(){
    $('#loader').css("display", "none", function() {
      $(this).remove();
    });
    $('html, body').css({
        'overflow': 'auto',
    })
})

On load负载

$( window ).on("load", function() {
    ...trigger load
});

When document loaded文档加载时

$( document ).ready(function() {
   ...remove loading
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM