随笔分类 - react
react
摘要:import { Prompt } from "react-router-dom"; const Login = () => { return ( <> <Prompt message={(location, action) => { // 返回 true 表示不拦截, 你可也检查当前页面数据,提示
阅读全文
摘要:@observable obj = { name: "ajanuw", age: 22, }; @computed get list() { return _.toPairs(this.obj); } {list.map(([k, v]) => (<div>{k}:{v}</div>))}
阅读全文
摘要:函数组件 必须为props定义 类型 export const Header = (props: { text: string }) => <h2>{props.text}</h2>; <Header text="hello" /> FC 类型包含children属性 export const He
阅读全文
posted @ 2018-12-24 23:50
Ajanuw
摘要:"文档地址" index.html util.js 使用
阅读全文
摘要:import LazyLoad from "react-lazyload"; function Placeholder() { return <img src={catJpg} />; } <ul> {this.images.map(el => ( <li key={el.id} > <LazyLo
阅读全文
posted @ 2018-12-21 21:59
Ajanuw
摘要:“ref”对象是一个通用容器,其current属性是可变的 保存dom 保存事件程序 存储以前的值
阅读全文
摘要:``` import { createForm } from "rc-form"; @createForm() class TopAdSlots extends Component { @observable vs = []; @action handlePickerChange = vs => { this.vs = vs; }; render() { ...
阅读全文
摘要:import React, { useState, useEffect, useContext } from "react"; import axios from "axios"; const l = console.log; const BodyContext = React.createCont
阅读全文
摘要:react hooks文档 设置 state import React, { useState } from "react"; const l = console.log; function Test() { const [n, setN] = useState(0); const [info, s
阅读全文
摘要:简单的日历组件 import React, { Component } from "react"; import as _ from "lodash"; const l = console.log; const weeks = ["日", "一", "二", "三", "四", "五", "六"];
阅读全文
摘要:"https://lbs.qq.com/tool/component picker.html" withMap 使用
阅读全文
摘要:"文档" 使用 loadable.js loading.js
阅读全文
摘要:"react文档" 为 类 添加ref 这种方法是获取组件的实例,而不是组件的dom 函数组件使用 ref 传递 refs 高阶组件中传递 ref
阅读全文
摘要:"文档" "https://gkedge.gitbooks.io/react router in the real/content/apache.html" nginx nginx.conf apache 修改httpd.conf Invalid command 'RewriteEngine', p
阅读全文
摘要:jest Enzyme 文档 为什么要写测试 单元测试(unit testing)指的是以软件的单元(unit)为单位,对软件进行测试。单元可以是一个函数,也可以是一个模块或组件。它的基本特征就是,只要输入不变,必定返回同样的输出。 单元测试的步骤如下 准备所有的测试条件 it('test a')
阅读全文
摘要:传递props import React, {Component, VFC, ReactNode } from 'react'; const Hello: VFC<{ body: ReactNode }> = ({ body }) => { return <div>{body}</div>; };
阅读全文
摘要:在构造函数里面 bing 获取点击事件的元素 传递参数 e.preventDefault(); 阻止默认行为 e.stopPropagation() 阻止事件传播(冒泡) "支持的事件名" rxjs 防抖 lodash 防抖 rxjs debounce
阅读全文