React-router


安装

npm install --save react-router-dom

使用

这里主要需要修改index.js,其内容改为官方示例代码:

import React from 'react';
import ReactDOM from 'react-dom';
import {
  BrowserRouter as Router,
  Route,
  Link
} from 'react-router-dom';

const BasicExample = () => (
  
    
  • Home
  • About
  • Topics

) const Home = () => (

Home

) const About = () => (

About

) const Topics = ({ match }) => (

Topics

  • Rendering with React
  • Components
  • Props v. State
(

Please select a topic.

)}/>
) const Topic = ({ match }) => (

{match.params.topicId}

) ReactDOM.render(, document.getElementById('main'));

你可能感兴趣的:(React-router)