随笔分类 - React从入门到改行
摘要:将 import { useRouter } from 'next/router'; 改为 import Router from "next/router"; 使用: Router.push('/'); 原来使用 import { useRouter } from 'next/router'; 会导
阅读全文
摘要:用JSON.stringify和JSON.parse处理下就可以了
阅读全文
摘要:说起来也奇怪,我在react中使用的是axios来请求数据,pc端和安卓端都能成功,部分iOS机型请求状态为0(status为0),回调 res为undefined。找了大半天也不知道原因,后来用 fetch 来请求数据如图(1-1)在iOS中正常。后面猜想是不是请求头上的原因,结果还真是这个问题,
阅读全文
摘要:import React,{ useState ,useRef} from 'react' const VrCornucopiaHome = () => { const [projectContent,setProjectContent] = useState() const [projectCon
阅读全文
摘要:html import React,{ useState } from 'react' const VrCornucopiaHome = () => { const bbbbb = () => { alert(1) } return ( <button type="button" onClick={
阅读全文
摘要:使用route 之前需要先安装 react-router-dom yarn add react-router-dom -D 在src根目录下新建router.js文件 //router.jsimport React,{ Component } from 'react' import {Route,
阅读全文
摘要:this.props.history.push('/home') 推荐使用 路由方式为 HashRouter
阅读全文
摘要:废话不多说,只讲干货axios的封装请移步到 https://www.cnblogs.com/tlfe/p/11911915.html 挂载在React原型上的时候是这么写的: 在index.js文件中 引入axios文件 import axios from './api/api' React.Co
阅读全文
摘要:import React from 'react' import './earnings.scss' import { ListView, PullToRefresh } from 'antd-mobile'; export default class Earnings extends React.
阅读全文
摘要:详情可查看github dome 演示文件 https://github.com/fuyunchun/react-redux-demo.git index.js 入口文件 import React from 'react'; import ReactDOM from 'react-dom'; imp
阅读全文
摘要:只需一步:在package.josn中添加如下代码 "proxy": "http://localhost:8091"
阅读全文
摘要:第一步: 安装babel-plugin-transform-decorators-legacy 模块和 @babel/plugin-proposal-decorators 模块 yarn add babel-plugin-transform-decorators-legacy --save-devy
阅读全文
摘要:这是使用connect装饰器报错, 解决办法, 第一步:安装如下模块 yarn add -D @babel/plugin-proposal-decorators 第二步:配置package.json文件下babel,在babel中添加如下配置 "plugins": [ ["@babel/plugin
阅读全文
摘要:第一步:安装sass yarn add sass -D yarn add sass-loader -D 第二步:使用sass import './index.scss' 注意:import './index.sass' 会报错,需要去配置webpack配置文件
阅读全文
摘要:这是安装element-ui后,运行react后报的错(意思就是说没有找到‘react-hot-loader’这个模块,那我们就装上这个模块) 在控制台中 yarn add react-hot-loader@next --save 再次运行项目
阅读全文
摘要:react为我们提供了两种获取value的方法 第一种:非受控方法获取 import React,{Component} from 'react' export default class system extends Component{ constructor(props){ super(pro
阅读全文
摘要:来看示例 我在Login自定义组件中引入了自定义组件system import React, { Component } from 'react'; import SYSTEM from './system' export default class Login extends Component{
阅读全文
摘要:父组件内 import React, { Component } from 'react'; import SYSTEM from './system' export default class Login extends Component{ constructor(props){ super(p
阅读全文

浙公网安备 33010602011771号