网上找的参考都是找到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);
}
再重新编译打包即可
下面是我自己项目的目录,根本就没有 react-scripts文件夹,那我改个鬼的路径呀- -。是不是某个版本之后移除了这个文件夹呀?我这里react的版本是16.7.0。。。