专栏名称: 前端JavaScript
分享 | 学习 | 交流 | 原创 分享是学习的开始;学习不必要从头开始,是从现在开始;交流能沟通你我,提高你的学识;期待你的加入!!! web前端技术交流,JavaScript,HTML5,CSS3……
目录
相关文章推荐
51好读  ›  专栏  ›  前端JavaScript

act闲谈——全新webpack2、react-router4架构,喜欢折腾的别错过!

前端JavaScript  · 公众号  · Javascript  · 2017-03-04 07:18

正文

请到「今天看啥」查看全文


);

====================================================================================


关于react-router4的新特性


API:react-router4做了较大的改变,看看提供了API就知道了。


BrowserRouter

HashRouter

MemoryRouter

ServerRouter

Match

Miss

Link

NavigationPrompt

Redirect

原则:react-router4的核心是组件。


(原文是这样的)The first principles of React Router are components, location, and Match.


Everything is a component; so, if you know React, you know React Router.

A location is data that represents where a visitor is–or wants to go–in your app. It looks just like window.location.

turns a location into UI.


翻译过来就是说:

React Router的 首要原则是组件 、location和Match。

所有路由都可以看成是一个组件 ,如果你会react,那么你就了解React Router,他们的核心是一样的,Match是一个组件,location是这个组件的一个参数,没错,这就是react组件的写法。


使用:假设现在有一个顶级容器App,用react-router的写法就是最外层用BrowserRouter来包裹,接着,你可以在里面写Link和Match这些子API,每个子路由组件还可以嵌套react组件或者路由组件,这就相当于你使用Link组件的时候可以嵌套多层DOM一样。







请到「今天看啥」查看全文