daily-share
daily-share copied to clipboard
个人博客记录、内容在issues
## 利用好dayjs库的利用 ```md 当前时间 dayjs() 时间字符串 dayjs('2018-06-03') 时间戳 dayjs(1528361259484) Date 对象 dayjs(new Date(2018,8,18)) 复制 dayjs().clone() 检测当前 Dayjs 对象是否是一个有效的时间 dayjs().isValid() 获取 年 : dayjs().year() 月 : dayjs().month() 日 : dayjs().date() 星期...
## 如何正确处理new Date() ```js // 如果你在new Date() 中传入了 "" , 那么你拿到的将是 invalid date new Date(); new Date(value); new Date(dateString); new Date(year, monthIndex [, day [, hours [, minutes [, seconds...
## reduce 方法处理一段代码 ```js class SyncWaterfallHook { constructor(arg) { this.tasks = [] // 存储监听函数 } tap(name, task) { this.tasks.push(task) } call(...args) { // 让监听函数的一个函数的返回结果是第一个监听函数的值 let [first, ...others] = this.tasks let...
# 处理虚拟键盘,输入(4.00) 失效的问题如何解决 背景: 在用户输入数字,处理虚拟键盘,输入4.00 ===> 变成 4 ,可以输入4.33 等 bug产生原因: 因为: (4.0).toString() // "4" 解决方案,在处理键盘数据时,统一处理成字符串,严禁在输入时有数字参与 ```js const strategys = new Map([ [/^\d$/, (keyCode: string) => { const prev =...
js运算符
## 指数运算符 ``` 2**2 // 4 2**2**2 // 16 // 对于第二种方式是先执行前面的指数运算,然后执行后面的指数运算! ```
## 如何拿到根元素操作dom呢? - bug 是小程序,opacity:0 在真机上会失效。。 > 有一个密码输入框的需求,需要做自定义的密码输入框,但是需要使用到input 框去聚焦和失去焦点来处理 ### 解决方案, > 通过input 的focus 的true和false来处理,效果不是很理想。
# 对于一个组件的点击事件,如何点击另一个,取消这次点击事件 > 可以采用input 的聚焦和失焦来做出判断!!! ```js import React from 'react' interface IState { show: boolean } export default class BasePopper extends React.Component { constructor(props: IProps) { super(props) this.state = {...
## create-react-app 2.x 自定义配置 [create-react-app 2.x 自定义配置](https://segmentfault.com/a/1190000018757322) [自定义配置 create-react-app ](https://zhuanlan.zhihu.com/p/40762397) [react ,基本webpack配置](https://www.cnblogs.com/zyl-Tara/p/10635033.html)
## react react-router中如何应对this.props.history.goBack() 返回两次或多次才生效的问题 > 最近在react项目中,封住了一个返回的组件。 采用this.props.history.goBack() 。返回上一级,但是由于这个页面有跳转编辑信息的页面,然后返回,点击返回按钮,点击两次才能返回到上一级。 ### 解决方案: ```tsx import React from 'react' import './nav-title.scss' import { Iconfont } from '@/components/icon-font/icon-font' import { RouteComponentProps, withRouter } from 'react-router-dom'...