存在兩個問題react
一,資源文件路徑react-router
config/paths.jsapp
這裏原來的.pathname:'/', 改爲.pathname:'./'dom
function getServedPath(appPackageJson) { const publicUrl = getPublicUrl(appPackageJson); const servedUrl = envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : './'); return ensureSlash(servedUrl, true); }
由此,背景圖片的地址多是url
.add-bank-sign { background: url("./../img/index.png"); //路徑前面加'./' }
二,當點擊路由跳轉的時候,會出現這樣的報錯spa
解決方案:code
routes/index.jsrouter
把原來的blog
import { BrowserRouter as Router,Route, Switch, Redirect } from 'react-router-dom'
改爲:圖片
import { HashRouter as Router, Route, Switch, Redirect } from 'react-router-dom'
就能夠了
固然開發的時候,最好BrowserRouter