react Cannot GET /
来源:互联网 发布:移动网络代理成电信的 编辑:程序博客网 时间:2024/06/08 09:03
如果是路由都配置好了,也没有报其他的编译错误,如下:
import dva, { connect } from 'dva';import { Router, Route } from 'dva/router';import React from 'react';import styles from './index.less';import key from 'keymaster';const app = dva();app.model({ namespace: 'count', state: { record: 0, current: 0, }, reducers: { add(state) { const newCurrent = state.current + 1; return { ...state, record: newCurrent > state.record ? newCurrent : state.record, current: newCurrent, }; }, minus(state) { return { ...state, current: state.current - 1}; }, }, effects: { *add(action, { call, put }) { yield call(delay, 1000); yield put({ type: 'minus' }); }, }, subscriptions: { keyboardWatcher({ dispatch }) { key('⌘+up, ctrl+up', () => { dispatch({type:'add'}) }); }, },});const CountApp = ({count, dispatch}) => { return ( <div className={styles.normal}> <div className={styles.record}>Highest Record: {count.record}</div> <div className={styles.current}>{count.current}</div> <div className={styles.button}> <button onClick={() => { dispatch({type: 'count/add'}); }}>+</button> </div> </div> );};// Helpersfunction delay(timeout){ return new Promise(resolve => { setTimeout(resolve, timeout); });}function mapStateToProps(state) { return { count: state.count };}const HomePage = connect(mapStateToProps)(CountApp);// const HomePage = () => <div>Hello Dva.</div>;app.router(({history}) => <Router history={history}> <Route path="/" component={HomePage} /> </Router>);// ---------app.start('#root');
那就说明你没有把 index.html 文件引入进来,加上 import ‘./index.html’; 这句话就好了
import dva, { connect } from 'dva';import { Router, Route } from 'dva/router';import React from 'react';import styles from './index.less';import key from 'keymaster';import './index.html';const app = dva();app.model({ namespace: 'count', state: { record: 0, current: 0, }, reducers: { add(state) { const newCurrent = state.current + 1; return { ...state, record: newCurrent > state.record ? newCurrent : state.record, current: newCurrent, }; }, minus(state) { return { ...state, current: state.current - 1}; }, }, effects: { *add(action, { call, put }) { yield call(delay, 1000); yield put({ type: 'minus' }); }, }, subscriptions: { keyboardWatcher({ dispatch }) { key('⌘+up, ctrl+up', () => { dispatch({type:'add'}) }); }, },});const CountApp = ({count, dispatch}) => { return ( <div className={styles.normal}> <div className={styles.record}>Highest Record: {count.record}</div> <div className={styles.current}>{count.current}</div> <div className={styles.button}> <button onClick={() => { dispatch({type: 'count/add'}); }}>+</button> </div> </div> );};// Helpersfunction delay(timeout){ return new Promise(resolve => { setTimeout(resolve, timeout); });}function mapStateToProps(state) { return { count: state.count };}const HomePage = connect(mapStateToProps)(CountApp);// const HomePage = () => <div>Hello Dva.</div>;app.router(({history}) => <Router history={history}> <Route path="/" component={HomePage} /> </Router>);// ---------app.start('#root');
阅读全文
0 0
- react Cannot GET /
- react Cannot find module
- React Native Get,Post请求
- cannot get volumn fstype alternative
- Kerberos:cannot get master principle
- 解决Cannot find module 'react/addons'
- React-native Cannot find module 'invariant'
- React Native error “Could not get BatchedBridge
- React-Native get和post请求
- React Native 解决 Could not get BatchedBridge
- Cannot get a connection, pool exhausted解决办法
- Cannot get a connection, pool exhausted解决办法
- error:cannot get C/H/S values
- Cannot get a connection, pool exhausted解决办法
- Cannot get a connection, pool exhausted
- [Tomcat]Cannot get a connection, pool exhausted
- Cannot get canonical host name for server
- Got error: getaddrinfo ENOTFOUND;Cannot GET
- PL/SQL Developer连接64位的Oracle(Oracle在本地已经安装)
- mfc解决其本身删除某一路径下文件夹的“缺陷”的办法
- MP4v2 Android
- Android assets文件夹资源的访问
- 线程范围内共享变量的概念与作用
- react Cannot GET /
- go学习笔记之bufio的使用
- gradle+maven+springboot实战
- Zxing实现工作原理之QRCode
- 1-12月英文
- 支付宝服务窗接入常见问题说明
- 如何形象理解OAuth(Open standard for Authorization)
- php字符串处理函数大全
- java 写数据时候,插入到指定行的位置