02 2023 档案
摘要:Refs为我们提供了一种方式访问Dom节点或者React实例,下面是使用Refs的几个场景 管理焦点,文本选择或媒体播放 触发强制动画 集成第三方 DOM 库 1. 创建和访问Refs 创建Refs Refs 是使用 React.createRef() 创建的,并通过 ref 属性附加到 React
阅读全文
摘要:1. Render Prop 具有 render prop 的组件接受一个返回 React元素的函数,并在组件内部通过调用此函数来 实现自己的渲染逻辑, 具体来说render prop 是一个用于告知组件需要渲染什么内容的函数 prop。 <DataProvider render={data =>
阅读全文
摘要:1. 创建Redux store app/store.js import { configureStore } from '@reduxjs/toolkit' export default configureStore({ reducer: {} }) 2. 将store提供给React index
阅读全文
摘要:1. store enhancer Store Enhancer基本结构 Store Enhancer是一个函数,这个函数可以接受一个createStore模样的函数为参数,返回一个新的createStore函数。它的主要目的是改变和加强store的接口方法。 const doNothingEnha
阅读全文
摘要:1. 什么是Redux Redux是一个通过叫做action的事件,管理和更新应用程序状态的js库或者说是一种模式。使用Redux 可以使我们更容易地理解应用程序中的状态或者说数据何时,何地,为什么被更新,以及这种更新所 带来的行为。 2. 使用Redux的场景 应用程序中具有大量的数据状态分布在程
阅读全文
摘要:1. 迭代器(Iterator) 特殊对象,具有迭代过程的接口next()方法 每次调用next()方法,返回一个结果对象 结果对象有两个属性value(任何类型)和done(布尔类型) 当集合的值返回完时,再次调用next()方法,结果对象的done属性值为true,value为迭代器最终返回的值
阅读全文
摘要:code/manifest.json { "manifest_version": 3, "name": "Code Tool", "description": "encode and decode string", "version": "1.0", "action": { "default_pop
阅读全文
摘要:getCustomizedObject /** * @number: the count of object attribute * @prefix: the object attribute prefix string * @value: the value of each attribute,
阅读全文
摘要:1. 正整数 正则表达式:/^(?!0)[0-9]+$/ 不以0开头 function isInteger(value) { return /^(?!0)[0-9]+$/.test(value); } 2. 非0数 正则表达式:/^\-?0\.[0-9]*[1-9]+[0-9]*$|^\-?(?!0
阅读全文
摘要:async/await其实是生成器的语法糖,async用于声明一个函数是异步的,而await用于等待一个异步方法执行完成,并且await只能出现在async函数中。 1. async 函数 async函数返回一个Promise对象,因此可以使用Promise对象的相关方法去进 一步处理async函数
阅读全文
摘要:Promise是异步编程的一种解决方案,它是一个对象,可以获取异步操作的消息,它解决了异步编程回调函数的地狱回调问题。 所谓Promise,简单说就是一个容器,里面保存着某个未来才会结束的事件(通常是一个异步操作)的结果。Promise提供了 统一的API,可以方便的处理各种异步问题。 1. Pro
阅读全文
摘要:initDSRProject.sh #!/usr/bin/bash # load utils . ./util/utils.sh . ./util/fileUtils.sh . ./util/gitUtils.sh # set project related info projectName="ro
阅读全文
摘要:syncMockJson.sh #!/usr/bin/bash # load utils . ./util/utils.sh . ./util/fileUtils.sh . ./util/gitUtils.sh # config directory, file path and branch ###
阅读全文
摘要:Web workders的规范让javascript在后台运行脱离了UI线程,从而解决了大量计算阻塞UI线程导致卡死的问题。 在Web workers没有出现之前,我们可以使用window.setTimeout 异步方式将计算包裹其中,来解决这种问题。 1. 使用 Web Workers Web W
阅读全文
摘要:shell-dsr/cron.sh #!/usr/bin/bash # execute shell script ################################################### # load utils . ./util/utils.sh declare -A
阅读全文
摘要:shell-dsr/utils.sh #!/usr/bin/bash # echo message with color ######################################################## function echoError { echo -e "\0
阅读全文
摘要:shell-dsr/updateVersionFlow.sh #!/usr/bin/bash # get current pwd pwd=$PWD # sync mock json for mc # . ./syncMockJson.sh declare -A versionDic versionD
阅读全文
摘要:~/.vim/my_configs.vim " Usefull setting set thesaurus+=~/js-functions.txt set thesaurus+=~/js-lodash.txt " Useful mappings " vnoremap <leader>. gv:wri
阅读全文
摘要:~/.bashrc # change cursor alias cl='echo -ne "\e[6 q"' alias cb='echo -ne "\e[2 q"' # set bash command line as vi mode # set -o vi # set CDPATH enviro
阅读全文
摘要:Start run project when run script start-work.sh #!/usr/bin/bash # start work . ~/utils.sh # jump to work directory uiProject=/c/project/path/ if [ -d
阅读全文
摘要:** use grep command to find selected words ** `vim-grep/` - `plugin/` `grep.vim` ``` function! s:GrepOperator(type) let l:saved_unnamed_register = @@
阅读全文
摘要:# test.vim test.vim is to test vimscript, and as an sample for developing the vundle plugin. 开发并安装一个本地 vundle 插件 第一步:按照 vundle 插件要求的目录结构,创建插件的目录结构 vim
阅读全文
摘要:###1. Intro This plugin can help you quikly convert the nls copy to nls key, such as "this is a nls", can convert to below keys list as you wanto. "F_
阅读全文
摘要:1. Introduction This is a simple tool for convert a long english sentence format to a nls key. 2. Install $ ./install.sh Open the git bash under the t
阅读全文