简体   繁体   English

我如何在 Svelte 中预加载所有组件和路由?

[英]How can i preload all components and routes in Svelte?

I have a game project based on Svelte.我有一个基于 Svelte 的游戏项目。 When the homepage opens, I want other pages to load the files as well.当主页打开时,我希望其他页面也加载文件。 For example, when you go to the lobby creation page from the home page, the images are loaded from scratch.例如,当您从主页 go 转到大厅创建页面时,图像将从头开始加载。

Anyone have experience with this?有人有这方面的经验吗?

You can add preload link elements to the <head> to preload files, they look like this:您可以将预加载链接元素添加到<head>以预加载文件,它们看起来像这样:

<link rel="preload" href="style.css" as="style" />
<link rel="preload" href="script.js" as="script" />

Valid as values can be found eg here .有效值可以在这里找到as

(Should be possible to those via <svelte:head> as well, but I never tried that.) (对于那些通过<svelte:head>的人来说应该也是可能的,但我从未尝试过。)

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

相关问题 如何为所有路由定义快速中间件 - How can I define express middleware for all routes 如何在 Nestjs 中获取所有路由(来自每个模块上可用的所有模块和控制器)? - How can I get all the routes (from all the modules and controllers available on each module) in Nestjs? 为了安全起见,除非添加特定于身份验证的中间件,否则如何强制所有路由未经授权? - For security purposes, how can I force all routes to be unauthorized unless I add auth-specific middleware? 如何在没有nodejs中所有路由的一个长文件的情况下进行路由? - How can I do my routing without having one long file of all the routes in nodejs? 如何在 Express 中为单个路由禁用 CORS 而无需重写我的所有路由? - How can I disable CORS for a single route in Express without rewriting all of my routes? 如何避免使用Express将所有路由添加到NodeJS中的app对象? - How can I avoid adding all routes to the app object in NodeJS with Express? 如何避免ExpressJS错误解释路线? - How can I avoid ExpressJS misinterpreting routes? 如何返回所有 URL 的苗条应用程序? - How to return the svelte app for all URLs? 如何正确设置路线? - How can I set the routes correctly? 我可以使用fs.readdir从/ routes /加载所有路由,并通过app.use(…)进行安装吗? - Can I load all routes from /routes/ with fs.readdir and mount with app.use(…)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM