react项目配置引入路由

要是用也是国际惯例,npm下!!

npm install -S react-router
  • 1

下完后直接import就可以使用,像这样

import { Router, Route, hashHistory } from 'react-router';
  • 1

Router是大壳子,类似于路由容器的东西

Route是具体实施路由的对象

hashHistory表示路由切换的hash值,决定最终结果


因为直接的项目结构比较建的随意,所以把目录进行了重新整理,把main.js变成一个大容器,不做任何业务主件使用,像这样。

热爱前端技术
原文地址:https://www.cnblogs.com/lcosima/p/8035044.html