• React create-react-app Unexpected end of JSON input while parsing near

    react 执行 create-react-app 时报这个错误, Unexpected end of JSON input while parsing near '...NATURE-----\r\n"},"en' 首先执行 npm cache clean --force 在重新安装一遍npm npm install npm -g 参考: https://www.jianshu.com/p/c7…

    学习 2021-04-24 2091

  • React路由页面刷新404

    nginx配置 跟vue的配置差不多, Vue路由页面刷新404问题:https://www.blyoo.com/2934.html server { ... location / { try_files $uri /index.html; } }

    学习 2019-06-06 3548

  • antd 时间组件DatePicker获取时间

    antd 选择日期的控件DatePicker是输出的时间对象 可以通过moment获取 首先安装moment npm install moment 引入moment 引入moment import moment from 'moment'; 使用moment time为取得表单里时间值 时间戳 moment(time).unix() //123456789 输出大众格式 moment(time).…

    学习 2019-05-18 9622

  • antd react-router 导航菜单刷新高亮

    我当前版本 "antd": "^3.16.5", "react": "^16.8.6", "react-router": "^5.0.0", 刷新高亮当前导航位置 app.js 注意一些点: withRouter需被包含在<Router>里,否则会报错的 import React, {Component} from 'react'; import {BrowserRouter as R…

    学习 2019-05-17 7403

  • Attempted import error: ‘Link’ is not exported from ‘react-router’.

    根据官方文档这么引入 import { Router, Route, Link } from 'react-router' 但是,报这个错误:Attempted import error: 'Link' is not exported from 'react-router'. 需要这么做 安装react-router-dom npm i react-router-dom -S 引入 import …

    学习 2019-04-26 5920

  • When specified, “proxy” in package.json must be a string.

    When specified, "proxy" in package.json must be a string. Instead, the type of "proxy" was "object". Either remove "proxy" from package.json, or make it a string. 配置React跨域时候 在网上看到是这样配置的,在package.json…

    学习 2019-03-16 9745

  • React 全家桶安装

    安装 npm install -g create-react-app 创建my-app项目 create-react-app my-app 进入my-app目录 cd my-app 启动 npm start 生成 npm run build

    学习 2019-03-07 2552

  • React 阻止默认事件和阻止冒泡

    首先有这样一段代码, 很久很久以前有这样一个故事,这要从远古时代说起 fn和fn1是一对父子 div是parent,span是children fn是子,fn1是父 最近在学react 首先 ... fn(ev){ alert('children') } fn1(ev){ alert('parent') } render() { return children } ... 一般情况下,原生js写法…

    学习 2019-03-07 9821

  • React Lifecycle生命周期

    还是Vue的生命周期命令好记,这个React的太特么长了 componentWillMount() //创建之前 componentDidMount() //创建之后 componentWillUpdate() //更新之前 componentDidUpdate() //更新之后 componentWillUnmount() //卸载之前 componentWillReceiveProps() /…

    学习 2019-02-16 2466