存在两个问题

一,资源文件路径

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

config/paths.js

这里原来的.pathname:'/', 改成.pathname:'./'

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

由此,背景图片的地址可能是

.add-bank-sign {
    background: url("./../img/index.png"); //路径前面加'./'
}

二,当点击路由跳转的时候,会出现这样的报错

 react build后直接从浏览器打开 随笔

解决方案:

routes/index.js

把原来的

import { BrowserRouter as Router,Route, Switch, Redirect } from 'react-router-dom'

改成:

import { HashRouter as Router, Route, Switch, Redirect } from 'react-router-dom'

就可以了

当然开发的时候,最好BrowserRouter

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄