react开发打包build发现路径不对解决

2024年04月01日 建站教程

react开发build发现路径不对怎么办,下面web建站小编给大家详细介绍一下解决方法!

找到node_modules -> react-scripts -> config -> paths.js

找到以下代码:

function getServedPath(appPackageJson) {
  const publicUrl = getPublicUrl(appPackageJson);
  const servedUrl =
    envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/');//改成'./'
  return ensureSlash(servedUrl, true);
}

改成以下代码:

function getServedPath(appPackageJson) {
  const publicUrl = getPublicUrl(appPackageJson);
  const servedUrl =
    envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : './');
  return ensureSlash(servedUrl, true);
}

重新打包~

本文链接:http://so.lmcjl.com/news/868/

展开阅读全文
相关内容