react-router-dom route

1, React route description

1.1, single-page application

Features single page was: one only need to load the main page, by partial refresh, you can achieve a jump or switch page

Advantages: faster loading speed, user experience is better

Disadvantages:

  • The first time you load a little slower than the traditional
  • Unfavorable seo
  • Page relatively complex
  • return key

1.2, the installation react-router-dom

In the project the command line, execute

cnpm install react-router-dom -S

Download to rely on the production environment.

In the assembly to an object obtained by deconstructing embodiment of react-router-dombuilt-in components in the assembly, the internal components introduced on demand, be used in the page:

  • HashRouter represents a root container route, all routes related to the future of things, must be wrapped in HashRouter inside, and a Web site, only need to use once HashRouter like;
  • Route represents a routing rule on the Route, there are two more important attributes, path, component
  • Link represents a route link to property
import {HashRouter,Route,Link} from 'react-router-dom'

Code Example:

render(){
        ret

Guess you like

Origin blog.csdn.net/p445098355/article/details/105217993