要加载 index.html 文件并使用 manifest.json 和 env.json 文件,您可以使用以下代码示例:
// 加载 manifest.json 文件
fetch('manifest.json')
.then(response => response.json())
.then(data => {
// 使用 manifest.json 中的信息
console.log(data);
})
.catch(error => {
console.error('Error loading manifest.json', error);
});
// 加载 env.json 文件
fetch('env.json')
.then(response => response.json())
.then(data => {
// 使用 env.json 中的信息
console.log(data);
})
.catch(error => {
console.error('Error loading env.json', error);
});
// 加载 index.html 文件
fetch('index.html')
.then(response => response.text())
.then(html => {
// 使用 index.html 中的内容
console.log(html);
})
.catch(error => {
console.error('Error loading index.html', error);
});
请注意,上述代码使用了 JavaScript 中的 fetch 函数来加载文件。您可以根据需要使用其他适合您的环境和需求的方法来加载这些文件。此外,这些代码示例假设您的文件位于与当前脚本相同的目录中。如果文件位于不同的目录,请相应地修改文件的路径。