龙风
龙风
## redux 数据模型 ```jsx export default { state: { count: 1, flag: false, data: { count: 1, name: 'zs', }, }, reducers: { addCount: (state, number) => { return {...
### 错误异常捕获组件 ```js /* * @Author: yaogeng.zhu * @Date: 2021-04-24 12:37:42 * @Last Modified by: yaogeng.zhu * @Last Modified time: 2021-04-24 13:14:58 */ import React from 'react'; import PropTypes from...
### 简单的使用方式 - hooks 方式实现 ```tsx import React, { useState } from 'react' import { DragDropContext, Droppable, Draggable, DropResult, DraggingStyle } from "react-beautiful-dnd" import { createUseStyles } from 'react-jss' const...
## iframe弹框为啥在iOS机器上圆角失效 ``` 在包裹的iframe元素div上给一个`position: relative` ```
### react 使用clipboard 一键复制 ```js const copyEvent = () => { const clipboard = new Clipboard('.copy') clipboard.on('success', (e) => { openToast(MessageType.success, '已复制到剪切板') }) clipboard.on('error', () => { openToast(MessageType.error, '不支持一键复制') })...
## 使用html2canvas 异常情况处理 - 问题1, 不能使用背景图 (使用div包裹一层) - 最好使用定位处理一些dom, css, -- html2处理会出现失效的情况 ```html ``` - 图片模糊问题、 图片不显示(图片跨越问题) ```js const canvasHtml = document.getElementById('wxShareCanvas') if (canvasHtml) { var opts = { scale:2,...
### CSS 多行省略失效 (-webkit-box-orient 失效) ```css .line-ellipsis-2{ display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; /* autoprefixer: off */ -webkit-box-orient: vertical; /* autoprefixer: on */ } ```
## 什么是高阶组件 > 高阶组件简单来说就是一个函数,接收一个组件作为一个参数,返回一个新的组件 ```tsx import React from 'react' import axios from 'axios' interface IState { data: string, isLoading: boolean } export const withLoader = (WrapperComponent: any, url: string) =>...
## 简单的了解发布与订阅模式(2020-1-19) > 简单的了解发布订阅模式,简单来说,发布订阅模式也是观察者模式。 ```js var salesOffices = {} salesOffices.clientLis = [] // 存放订阅的函数 salesOffices.listen = function(fn) { // 添加订阅者 this.clientLis.push(fn) } salesOffices.trigger = function() { // 发布消息 for(var i...