![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
工具
百里登风
这个作者很懒,什么都没留下…
展开
-
如何关闭eslint相关规则
根目录创建 .eslintrc.jsmodule.exports = { xxx: 'xxx', overrides: [ { files: ['*.ts', '*.tsx'], rules: { '@typescript-eslint/no-namespace': 0, '@typescript-eslint/no-use-before-define': 0, '@typescript-eslint/no-unuse原创 2022-01-19 17:47:45 · 996 阅读 · 0 评论 -
js 获取伪类和css变量
获取css变量getComputedStyle(document.documentElement) .getPropertyValue('--primary-color'); 获取伪类元素var dom = getComputedStyle(document.body, '::before');原创 2022-01-04 16:41:07 · 922 阅读 · 0 评论 -
js 数字不足位数补0
方式一,使用padStart'9'.padStart(2,0);// 09方式二,使用Intl.NumberFormatnew Intl.NumberFormat(undefined, { minimumIntegerDigits: 2, useGrouping:false}).format(9);//09原创 2021-10-28 12:12:02 · 2209 阅读 · 0 评论 -
算法来为图像找到好的裁剪
算法来为图像找到好的裁剪Smartcrop.js 实现了一种算法来为图像找到好的裁剪。它可以在浏览器中、节点中或通过 CLI 使用。原创 2021-09-07 19:41:37 · 190 阅读 · 0 评论 -
获取当前日期的周开始时间周结束时间
原生js获取周的开始时间和结束时间/** * 获取当前日期的周开始时间和周结束时间 * @example * getWeekDate(new Date()) =>{ weekStartDate: new Date(), weekEndDate: new Date() } */export const getWeekDate = (date: Date, format?: (date: Date) => string) => { const nowDayOfWeek =原创 2021-02-07 20:54:30 · 579 阅读 · 1 评论 -
vscode代码片段,react模版
{ // 在此处放置您的片段。 每个代码段均以代码段名称定义,并具有范围,前缀,主体和 // 描述。 在范围字段中添加代码段适用的语言的逗号分隔ID。 如果范围 // 如果保留为空或省略,则代码段将应用于所有语言。 前缀是什么 // 用于触发代码段,然后将展开并插入正文。 可能的变量是: // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placehold原创 2020-08-09 11:44:19 · 1120 阅读 · 0 评论 -
toFixed 四舍五入的问题
原生toFixed , 会有四舍五入的问题,所以自己封装一个方法/** *和原生toFixed的区别在于这个没有四舍五入 * @example * toFixed(2.999,1) === '2.9' * @export * @param {(string | number)} target 要转换的字符串或者数字 * @param {number} num 保留多少位小数 * @returns {string} */export function toFixed(target: .原创 2020-07-20 11:19:27 · 673 阅读 · 0 评论 -
webpack 配置 alias
webpack 配置 alias 后很方便,有时有我们项目比较大,比较复杂的时候尤为重要const path = require('path');const resolvePath = relativePath => path.resolve(process.cwd(), relativePath);{....alias: { '@': resolvePath('src'), '@common': '../../common', }, }原创 2020-07-03 17:16:30 · 4529 阅读 · 0 评论 -
TS 使用React , forwardRef写一个复制文本组件
React.forwardRef 接收一个函数组件useImperativeHandle 返回暴露的ref的具体类型import React, { useRef, useImperativeHandle } from 'react';import ReactDOM from 'react-dom';interface CopyProps { text: string;}interface InputRefProps { copy(): void;}/** * 复制文本input原创 2020-06-17 20:41:25 · 3829 阅读 · 0 评论 -
typeorm自动生成实体类
可以使用typeorm-cli自动生成1. 安装typeorm-clinpm nstall -g typeorm-cli2. 使用安装好之后就可以在 typeorm项目根目录下允许 typeorm-cli 就可以了3 配置在更目录下的 ormconfig.json 添加配置4 自定义模板在根目录下添加 ormEntityTemplate.ejs 文件,实现自定义模版5 注意目前仅测试了 mysql命名规则采用下划线区分如果当前生成的和上次的不一样,会自动备份一次...原创 2020-05-24 21:57:48 · 2365 阅读 · 0 评论 -
递归Partial类型
/** * 递归Partial类型 */export type PowerPartial<T> = { // 如果是 object,则递归类型 [U in keyof T]?: T[U] extends object ? PowerPartial<T[U]> : T[U];};原创 2020-05-19 10:50:58 · 443 阅读 · 0 评论