xxx
This commit is contained in:
@@ -1,12 +1,35 @@
|
||||
import React from 'react'
|
||||
class Login extends React.Component{
|
||||
constructor(){
|
||||
super()
|
||||
super();
|
||||
this.state={
|
||||
userName:'',
|
||||
password:''
|
||||
}
|
||||
}
|
||||
render(){
|
||||
return(
|
||||
<div>
|
||||
<h1>欢迎登录</h1>
|
||||
<ul>
|
||||
<li>用户名</li>
|
||||
<li>
|
||||
<input type="text"
|
||||
placeholder="请输入用户名"
|
||||
onChange={(e)=>{this.setState({userName:e.target.value})}}
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>密码</li>
|
||||
<li>
|
||||
<input type="text"
|
||||
placeholder="请输入用户名"
|
||||
onChange={(e)=>{this.setState({userName:e.target.value})}}
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
<button type="button">立即登录</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ class Nav extends React.Component{
|
||||
render(){
|
||||
return(
|
||||
<ul className="nav">
|
||||
<li onClick={this.go.bind(this,'/shop/login')}>登录</li>
|
||||
<li onClick={this.go.bind(this,'/shop/index')}>首页</li>
|
||||
<li onClick={this.go.bind(this,'/shop/good')}>商品</li>
|
||||
<li onClick={this.go.bind(this,'/shop/car')}>购物车</li>
|
||||
|
||||
@@ -5,7 +5,7 @@ const Index=lazy(()=>import('./index'))
|
||||
const Good=lazy(()=>import('./good'))
|
||||
const Me=lazy(()=>import('./me'))
|
||||
const Car=lazy(()=>import('./car'))
|
||||
const Login=lazy(()=>import('./login'))
|
||||
|
||||
class Shop extends React.Component{
|
||||
render(){
|
||||
return(
|
||||
@@ -18,7 +18,6 @@ class Shop extends React.Component{
|
||||
<Route path="/shop/good" component={Good}></Route>
|
||||
<Route path="/shop/me" component={Me}></Route>
|
||||
<Route path="/shop/car" component={Car}></Route>
|
||||
<Route path="/shop/login" component={Login}></Route>
|
||||
<Redirect to="/shop/good"></Redirect>
|
||||
</Suspense>
|
||||
</Switch>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import React, {lazy,Suspense} from 'react'
|
||||
import {HashRouter,Route} from 'react-router-dom'
|
||||
const Shop=lazy(()=>import('./pages/shop'))
|
||||
const Login=lazy(()=>import('./pages/login'))
|
||||
class Router extends React.Component{
|
||||
render(){
|
||||
return(
|
||||
@@ -14,8 +15,9 @@ class Router extends React.Component{
|
||||
<HashRouter>
|
||||
<React.Fragment>
|
||||
<Suspense fallback={<React.Fragment></React.Fragment>}>
|
||||
<Route path='/' exact component={Shop}></Route>
|
||||
<Route path='/' exact component={Login}></Route>
|
||||
<Route path='/shop' component={Shop}></Route>
|
||||
<Route path='/login' component={Login}></Route>
|
||||
</Suspense>
|
||||
</React.Fragment>
|
||||
</HashRouter>
|
||||
|
||||
Reference in New Issue
Block a user