, css, html) = show (page display)
Implementation logic of react-router:
Jump = "path =" component = "static resources (js, css, html) =" show (page display)This article focuses on react-router. The following describes how to use react-r
Today this problem for a long time, finally find out why, we search this problem in Baidu basically only one answer click Open link
In fact, it is not to say that people answer the wrong, but more vague, see screenshots:
In fact, the answer is this, when we use React-router, React-router's idea is to let us
Remember: Be sure to establish an association in thi
Detailed explanation of how react-router implements on-demand loading; detailed explanation of react-router
Note: The react-router version used in this article is 2.8.1.
React
Create-react-app is from Facebook, which allows us to quickly build a react development environment without configuration.Create-react-app automatically created projects are based on Webpack + ES6The following commands are executed:NPM Install create-react-app-g // Global Installation Create-
Simple descriptionThis article is my study react one months of summary, starting from the basics (including editor settings, build tools), step by step toward react development. Believe me, after reading this article, follow the steps of the article go, to ensure that you get started react and love react, Master
This article mainly introduces the use of React-router and webpack how to quickly build a react program, the following words not to say, interested can learn together.
Initializing a project
We first create an empty folder, then initialize the Package.json and fill in some basic information.
$ NPM Init
Next we start to install the dependencies, and
development environment NPM install Webpack--save-dev
Local installation to production environment NPM install Webpack--save
The specific definitions of these three environments can be queried on their own.Next need to install Babel (transcoding), React, React-dom, eslint (grammar detection), here I do not say the method of installation, directly put the configuration, we directlyInstall"Devdepend
Vue. js uses vue-router to redirect to a page. vue. jsvue-router
Preface
When using Vue. js for a project, a page consists of multiple components. Therefore, the traditional href is not suitable when you jump to the page. Therefore, vue-router came into being.
Official documents: https://router.vuejs.org/zh-cn/essentia
SceneUse react to do development and avoid using React-router
React Router is already a V4 version.
React RouterNow it has been divided into three packages: react-
When history is not added, clicking link back and forth will report the following error in the console:Warning: Hash history cannot push the same path; a new entry will not be added to the history stackThe solution is to install and use the history module.Import createbrowserhistory from "History/createbrowserhistory"; const customhistory = createbrowserhistory (); Note that the introduced hashrouter is changed to a router.How does a REACT project use
Scene
Use react to do development and avoid using React-router
React Router is already a V4 version.
React RouterNow it has been divided into three packages:react-router
This tutorial is a total of 6, daily update one, please pay attention to us! You can go to historical news to view previous articles, and also please look forward to our new articles!
1, React third party component 1 (Routing management router use ① simple use)---2018.01.22
2, React third party component 1 (Routing management
CP from:https://www.jianshu.com/p/6a45e2dfc9d9The root of all evilFrom React Router V4 officially released also has been in the past three months, this week to upgrade a react shelf, before the route with the v2.7.0 version, so decided to upgrade the route, just "Taste fresh" ...Rumors, the current official maintenance of 2.x and 4.x two versions. (ヾ? ﹏?)?? Yi, n
React Router 4.0 (hereinafter referred to as RR4) has been officially released, it follows the react design concept that everything is a component. So RR4 is just a bunch of components that provide navigation (and a number of objects and methods), with a declarative (in-use), and a combination of features. http://www.jianshu.com/p/e3adc9b5f75c
RR4 this time using
React-router v4,
Preface
It has been a long time since React Router v4 was officially released. This week, a React shelf was upgraded, and the previous route was still in v2.7.0, so I decided to upgrade the route, just to "Try it "...
It is rumored that both 2.x and 4.x vers
Project StructureImage.png
-routermap page, all pages must be registered for routing
Import React from ' React ' import {Router, Route, indexroute} from ' React-router ' import apps from '. /containers ' Import Home from '. /containers/home ' Import city from '. /container
Webpack4. X React-routerEnvironmental preparedness: Windows7, Webstorm 2017.1.4, Nodejs 8.7.0, NPM 5.4.2PS: When installing, we all bring the version, so even if the webpack version changes, there will be no version issue.Initializing the Package.json fileNPM InitNPM installs react, react-dom packagesOrNPM i-s [email protected] [email protected]NPM installs Webpa
One, what is load on demandAs with the asynchronous load script (asynchronously loading the script method), on-demand load/code cutting can also solve the first screen loading speed.
When you need to load on demand
If it is a large file, it is appropriate to use on-demand loading. For example, a nearly 1M of national cities and counties of the JSON file, when I load the first screen does not need to be introduced, but when the user click on the option to load. If you do not click,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.