Does the picture fail under the nesting of react router routes?

is developed by create-react-app, and there is a nested route, such as

like home/music.

on the home page, the picture can be displayed, and the request address is correct static/media/ , but under home/music, a home, is added to the path in front of the image to become home/static/media/

.

my nested route looks like this

        <Route path="/home" exact component={FindMusic} />
        <Route path="/home/fmusic" exact component={FindMusic} />
        <Route path="/home/fradio" exact component={RadioPage} />

I wonder if it is written in this way?

the main route is written as follows:

    <Switch>
        <Route path="/home" component={AsyncHome} ></Route>
        <Route path="/video" component={AsyncVideo} ></Route>
        <Route path="/mymusic" component={AsyncMyMusic} ></Route>
        <Route path="/friends" component={AsyncMyFriends} ></Route>
        <Route path="/user" component={AsyncUser} ></Route>
    </Switch>

the path of the picture is written like this:

import daypushbtn from "./images/daypushbtn.svg"
import fmbtn from "./images/fmbtn.svg"
import musiclistbtn from "./images/musiclistbtn.svg"
import rankbtn from "./images/rankbtn.svg"

const switchImg = (e) =>
{
    switch (e.props.name) {
        case "FM":
            return fmbtn
            break;
        case "":
            return daypushbtn
            break;
        case "":
            return musiclistbtn
            break;
        case "":
            return rankbtn
            break;


    }
} 

export class DayPushItem extends Component {
  render() {
    return (
      <div className="DayPushItem">
            <div className="itemImg">
                <img src={switchImg(this)}/>
            </div>
            <div className="itemText">{this.props.name}</div>
      </div>
    )
  }
}

export default DayPushItem



online address: http://react.packy.club/ is idle to learn react and wants to imitate a NetEase music

Sorry, I read it wrong. The address of the picture has not changed. But the address cannot be requested, as shown in the following figure:
Private FM. The picture in the daily recommendation, playlist and ranking is wrong.

main domain name home/

home/fmusic

:

:

is this because the relative path is used when the picture is introduced? But when my create-react-app writes an alias, build will make an error.

my react-route uses BrowserRouter and apache server, so A. htaccess is configured in the project root directory so that the project refresh will not be 404.


did you explain the path of the picture?


the path of the picture is posted to see


the picture is introduced by require, such as: require ('. / images/test.png');
add a url-loader plug-in project with examples: https://github.com/meibin08/e.


Hello, has the problem been solved

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1beb505-31a6e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1beb505-31a6e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?