Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/462.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
绑定webpack后,如何更改Javascript创建页面的href?_Javascript_Html_Webpack_Module - Fatal编程技术网

绑定webpack后,如何更改Javascript创建页面的href?

绑定webpack后,如何更改Javascript创建页面的href?,javascript,html,webpack,module,Javascript,Html,Webpack,Module,我试图在项目中使用webpack,但在动态创建页面时遇到问题。 我为页眉、页脚和另一个页面动态创建了三个模块 根据header.js中的示例,我有一个带有链接的导航栏,如“/src/html/about.html” 当我从src文件夹运行live服务器时,我没有遇到任何问题。当我运行webpack并将所有内容打包到dist文件夹时,问题就出现了。.js文件中的路径无法更改,my index.html无法正确加载它们 header.js看起来像这样,但更长,例如navbarLogo.href: c

我试图在项目中使用webpack,但在动态创建页面时遇到问题。 我为页眉、页脚和另一个页面动态创建了三个模块

根据header.js中的示例,我有一个带有链接的导航栏,如“/src/html/about.html”

当我从src文件夹运行live服务器时,我没有遇到任何问题。当我运行webpack并将所有内容打包到dist文件夹时,问题就出现了。.js文件中的路径无法更改,my index.html无法正确加载它们

header.js看起来像这样,但更长,例如navbarLogo.href:

const displayHeader = () => {
const navbar = document.createElement('div');
    navbar.classList.add('navbar');
    centeredContainer.appendChild(navbar);

const navbarLogo = document.createElement('a');
    navbarLogo.classList.add('navbar-logo');
    navbarLogo.href = "/src/index.html";
    navbar.appendChild(navbarLogo);
}

export default displayHeader;

您知道如何处理这些类型的路径问题吗?

请添加一些代码@马杜奈尔:哦,对不起,现在结束了!