如何延迟 Razor 应用程序加载时间以进行调试?

问题描述 投票:0回答:1
c# razor blazor webassembly
1个回答
0
投票
1.  Delay the Blazor startup:

您可以修改 index.html 文件并在 Blazor 开始执行之前添加手动延迟,方法是使用 JavaScript 的 setTimeout 函数来延迟对 Blazor.start() 的调用。

2.  Modify the index.html:

您可以手动控制启动时间,而不是让 Blazor 自动启动,如下所示:

<body>
    <div class="dark loading-section" id="app">
        <div class="loading-content">
            <!-- You can add more specific debug elements here if necessary -->
            <p>Loading...</p>
        </div>
    </div>
    <div id="blazor-error-ui">
        An unhandled error has occurred.
        <a href="" class="reload">Reload</a>
        <a class="dismiss">🗙</a>
    </div>

    <script src="_framework/blazor.webassembly.js" autostart="false"></script>

    <script>
        // Add a manual delay before starting Blazor (e.g., 3 seconds)
        setTimeout(function () {
            Blazor.start();
        }, 3000); // Delay for 3000 ms (3 seconds)
    </script>
</body>
© www.soinside.com 2019 - 2024. All rights reserved.