1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import React from "react" import {connect} from "react-redux" import {login} from "./Auth.redux" import {Redirect} from "react-router-dom" import {axios} from 'axios' @connect( state=>state.auth, {login} ) class Auth extends React.Component{ componentDidMount() { axios.get('/data') .then(res=>{ console.log(res) }) } render(){ return ( < div > {this.props.isAuth ? < Redirect to = '/dashboard' ></ Redirect > : null} < h2 >你上未登入,須登入才能看</ h2 > < button onClick={this.props.login}>登入</ button > </ div > ) } } export default Auth |
1 | "proxy": "http://localhost:9093" |
不知哪錯了,總覺得好像沒到9093端口~~
全网唯一的React 16+Redux+React Router4实战课程,学到手是你的真本领!
了解课程