你可以用这个
<link rel="prefetch" href="/data.json" as="fetch">
这样,浏览器将从缓存中加载资源,而不是在您要使用该文件时再次前往服务器请求该文件。
fetch('/data.json') .then(response => { // some code }) .then(json => { // some code }) .catch(console.error);