
react
证证乐乐
想仅仅通过文字的力量,留住一丝情怀和温暖
展开
-
react生命周期
shouldComponentUpdate(nextProps, nextState) { if(this.props == nextProps && this.state == nextState) { return false; } return true; } ````原创 2019-11-21 17:37:21 · 114 阅读 · 0 评论 -
redux的应用
1,先在需要用到的地方注入//获取码表数据import { connect } from 'react-redux';//获取费用类型import { getDictAll } from '@actions/dictAction';@connect( state => ({ user: state.userReducers }), { getDictAll,setDict }...原创 2019-11-15 17:34:49 · 190 阅读 · 0 评论 -
屏幕弹字
import React, { Component } from 'react';export default class Test extends Component {/** * 字浮动 * @param {*} props */ constructor(props) { super(props); this.state = { ...原创 2019-11-08 16:48:22 · 321 阅读 · 0 评论 -
Input框只能输入数字
type=“number”<Input type="number" addonAfter={<span onClick={this.showModal3}>换算</span>} placeholder="请输入本年度计划支付金额" />原创 2019-11-04 11:41:34 · 691 阅读 · 0 评论 -
验证特殊字符
// 验证特殊字符 if(/[~#^%&!*]/gi.test(money)) { return false; }原创 2019-11-04 10:17:37 · 546 阅读 · 0 评论 -
formCreate
Form.createimport React, { Component } from 'react';import { Form, Row, Col, Input, Radio, Button, Switch, message } from 'antd';// import Bus from '@utils/bus.js';import { POST } from '@http/ind...原创 2019-10-30 20:17:38 · 2383 阅读 · 0 评论 -
值发生改变时调用componentWillReceiveProps
/** * 组件的生命周期分成三个状态: * Mounting:已插入真实 DOM * Updating:正在被重新渲染 * Unmounting:已移出真实 DOM * React 为每个状态都提供了两种处理函数,will 函数在进入状态之前调用,did 函数在进入状态之后调用,三种状态共计五种处理函数。 * * componentWillMount() * c...原创 2019-10-30 20:06:30 · 473 阅读 · 0 评论 -
Modal框需要三个按钮,footer
当需要三个按钮时,写个组件footer={buttons} <Modal width="400px" title="选择外包服务" visible={this.state.visible3} footer={buttons} maskClosable={false} destroyOnClose={true} cl...原创 2019-10-29 16:42:49 · 6674 阅读 · 2 评论 -
声明式调用方法
onClick={e => this.showReport(e, '2')}this.props.showReport(e, type);onclick={(e) => {this.showReport(e) }}// 直接调用this.showReport()原创 2019-10-24 17:42:23 · 420 阅读 · 0 评论 -
Checkbox全选,push
一直以来最不熟悉的就是写组件1,先准备点假数据 this.options = [ { label: '年份', value: 'year' }, { label: '外包服务名称', value: 'serviceName' }, { label: '项目编号', value: 'approvalNumber' }, { label: '项目名称', value: '...原创 2019-10-24 10:06:22 · 244 阅读 · 0 评论 -
Search组件 不支持OnBlur,onChang又只能每次获取上一次输入的值,用验证在调用方法
<Row gutter={24}> <Col span={3}> <Form.Item className="textAlignR"> <span className="color-red">*</span> <span>...原创 2019-10-22 17:44:44 · 458 阅读 · 0 评论 -
react取key和value
{0:213456787654321}1:取key // 查询数据的方法 searchData = values => { for (var i in values) { if (i != 'keyword') { } }2,取value…keyword原创 2019-09-26 17:15:23 · 3740 阅读 · 0 评论 -
悬浮关闭,从表单获取id,实时验证,下拉菜单,字符串转日期,页面自己定到错误的地方,按照词根进行分类,提示
1,悬浮关闭按钮<div className="ant-drawer-footer" style={{ width: '600' }}> <Button style={{ marginLeft: 8 }} onClick={this.props.onClose}> 关闭 </Button></div>2,抽屉的关...原创 2019-07-18 14:47:47 · 212 阅读 · 0 评论 -
react的基本使用
一: 组件的复用二:获取后端给的数据并展示到页面上import React, { Component } from 'react';import axios from 'axios';class Test extends Component { constructor(props) { super(props); this.state = { ...原创 2019-02-19 17:00:11 · 393 阅读 · 0 评论 -
react合并单元格
举个例子,假如我们要合并2019年这一年的年份/** * 合并单元格 * @param text 当前的值 * @param array 当前这一行的数据 * @param columns 当前的key 也就是year * @returns {number} */ // 定义一个变量,因为初始化的时候第一行是个空let temp = {};let tempNum...原创 2019-05-05 15:15:20 · 1507 阅读 · 0 评论 -
ES5和6的一些新特性
ES5和6的一些新特性更详细的大家参考:阮一峰的ES6教程1.1.let 和 const 命令var之前,js定义变量只有一个关键字:varvar有一个问题,就是定义的变量有时会莫名奇妙的成为全局变量。例如这样的一段代码:for(var i = 0; i < 5; i++){ console.log(i);}console.log("循环外:" + i)你猜下打印...原创 2019-02-14 10:30:57 · 1384 阅读 · 0 评论 -
react阶段性总结
1. React 的定义react 是一种以数据为驱动的大视图,提供了一种高性能,组件化的技术解决方案。1. 数据为驱动:在 react 中任何视图的改变,都来源于 state 或 props 的改变所引起的class template extends Component { constructor(props) { super(props); this.state = { /...原创 2019-05-05 19:37:34 · 380 阅读 · 0 评论 -
react 在点击查看的时候禁用整个表单,前提新增,编辑,查看用的是一个表单
在这个表单render下添加let { getFieldDecorator } = this.props.form; if (this.props.disabled) { getFieldDecorator = (...rest) => { return element => { let NewElement = React.cloneElement(e...原创 2019-05-14 16:17:28 · 4335 阅读 · 1 评论 -
高阶组件 wrappedComponentRef 获取组件的引用
父调子 有这句话的时候 继续封装了一层 const Contractdef = Form.create({ name: 'def ’ })(def );class abc extends Component { constructor(props) { super(props); this.state = { // state设置一个id id: '' }...原创 2019-05-07 10:33:50 · 15641 阅读 · 0 评论 -
react 异常页面500
首先准备一张图片import React, { Component } from 'react';import { Row, Col } from 'antd';import er from './500error.png';import { browserHistory } from 'react-router';/** * [错误处理组件, 404/500] * @exten...原创 2019-06-17 18:26:47 · 2001 阅读 · 0 评论 -
提示用户
import React, { Component } from 'react';import { Popover, Icon} from 'antd';<Row gutter={24}> <Col span={4}> <Form.Item className="textAlignR"> <span>a:</...原创 2019-06-17 18:36:19 · 195 阅读 · 0 评论 -
在visual Studio 安装 react插件
1. 创建本地文件夹,即保存项目的文件夹,在文件夹下打开控制台我这里使用git bash直接在文件夹下右键找到git bash启动即可2. 在控制台输入 npm install -g create-react-app 使用npm安装 create-react-app3. 安装完 create-react-app 之后 继续输入 create-react-app my-app 来创建一...原创 2019-02-19 16:20:21 · 3433 阅读 · 0 评论