繁体   English   中英

Vue.js 构建器在索引中生成不正确的路径。html

[英]Vue.js builder produces incorrect paths in index.html

问题是在目标文件夹中构建 vue 应用程序后, index.html 与 static 资产的路径不正确。 链接看起来像

<link href="/static/js/chunk-29e00bf1.49e28fbb.js" rel="prefetch">

这是不正确的,但应该是

<link href="static/js/chunk-29e00bf1.49e28fbb.js" rel="prefetch">

并且浏览器查看 ///D:/static/js/ 而不是 D://.../build/dist/static/js。

有我的 vue.config.js

module.exports = {
  outputDir: './build/dist/',
  assetsDir: './static', //...

使用publicPath属性,并将路径设置为./以在构建时使用相对路径。

module.exports = {
    ...
    publicPath: "./"
    ...
}

在官方文档中阅读更多信息: publicPath

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM