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')
相關文章
相關標籤/搜索