React对比Vue(06 路由的对比)

其实差很少,html

都须要先安装路由vue

React  先安装  react

cnpm install react-router-dom --save
在再根组件引入
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
这个严格匹配要注意(vue没有好像)
 
 

 

这个动态路由传值,对应 的组件获取值 在DidMount里面去获取  npm

this.props.match.params
vue的话是this.$route.params.xx或者query.xx   详情看https://www.cnblogs.com/zhangruiqi/p/9412539.html

 

 

 

react获取get传值的话能够安装urlreact-router

模块,方便易用贬值dom

 

 

********************************************************************************************************固然平时都用的是点击事件去跳转路由******************************************************************************************************************************************************************ui

vue中  this

this.$router.push();

React 4.x router 中是: this.props.history.push('/xxx')
相关文章
相关标签/搜索