[英]How to add html file into different js folder
pic I want to add html file in my js, and this pic is the path in my directory.图片我想在我的js中添加html文件,这张图片是我目录中的路径。 How can I do?我能怎么做?
in my config.js, I widh to include my file as let ADDR_iframe1 = "../templates/switch.html";
在我的 config.js 中,我将我的文件包含为let ADDR_iframe1 = "../templates/switch.html";
Use JavaScript fetch() Method to Load an External HTML File.使用 JavaScript fetch() 方法加载外部 HTML 文件。 Please find the below example for your reference.请找到以下示例供您参考。
function loadHTML() {
fetch('switch.html')
.then(response=> response.text())
.then(text=> document.getElementById('xyz').innerHTML = text);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.