自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(17)
  • 收藏
  • 关注

原创 react函数组件使用useState创建的变量的异步问题解决思路

const [value, setValue] = useState(null);const [value2, setValue2] = useState(null);问题:需要在setValue之后立马调用setValue2

2022-11-21 16:32:55 894

原创 react antd useForm:函数组件中通过useForm创建的表单实例通过form.getFieldValue获取数据undefined的问题

React函数组件推荐使用useForm管理表单数据,使得表单成为非受控组件,不用通过useState创建state维护数据。

2022-08-04 11:55:22 4814

原创 typescript基本类型

令人困惑的是,这里的冒号不是指示类型的。如果你想指定它的类型,仍然需要在其后写上完整的模式。(1)数组let[first,…rest]=[1,2,3,4];never类型表示的是那些永不存在的值的类型。两种形式,一种是,一种是as。...

2022-07-19 11:34:01 399

原创 vue this的理解

vue组件包括:每一个vue组件都是一个VueComponent的实例。VueComponent:$attrs: (...)$children: []$createElement: ƒ (a, b, c, d)$el: div$listeners: (...)$options: {parent: VueComponent, _parentVnode: VNode, propsData: undefined, _parentListeners: undefined, _renderChildre

2022-05-12 23:17:57 473

原创 vue+webpack实现vue项目多入口

需求:项目中需要在一个vue项目中实现多个入口一般的vue项目入口文件是html.html,但是若是想要实现多入口文件,就需要通过webpack进行配置。实现过程如下:(以添加newEntry为例)1.在项目根路径下添加newEntry.html文件,id=newEntry2.在src文件下添加newEntry.js和NewEntry,vue文件,在newEntry.js引入NewEntry,vue文件。new Vue({ el: '#newEntry', route

2022-05-12 15:19:32 1350

原创 vue插槽

插槽的作用vue 父子组件中,子组件提供给插槽,以供父组件在指定位置插入组件使用方法1.子组件提供<slot></slot>,父组件在子组件中直接插入即可。2.子组件提供<slot name='name1'></slot>,父组件中<template slot='name1'></template>3.子组件提供<slot :value1='value1'></slot>,父组件中使用<tem

2022-05-12 00:11:50 198

原创 vue父子组件之间传参及传方法

vue组件之间传参和传方法

2022-05-09 15:33:02 992

原创 js设计模式之观察者模式(发布订阅模式)

一、基本思想:<!doctype html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <me

2022-03-29 15:59:06 114

原创 js Promise

Promise处理异步程序一、使用then/catch/finally处理异步结束之后的操作1.then:then可以只处理成功的函数new Promise((resolve,reject)=>{setTimeout(()=>{resolve(‘success!’)},3000)}).then(success => console.log(‘success’,success),error => console.log(‘error’,error))使用await更优

2022-03-18 16:34:27 303

原创 “基于回调”的异步编程风格

function loadScript(src, callback) {let script = document.createElement(‘script’);script.src = src;script.onload = () => callback(script);document.head.append(script);}loadScript(‘https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.2.0/lodash.js’,

2022-03-18 14:10:14 240

原创 try...catch...finally 与 return

1.try中有return,虽然finnally中的代码会执行,但是但会的却是try中的返回值。always2.try,finally中都有return ,则返回的是finally中的值

2022-03-18 13:30:19 177

原创 try/catch与setTimeout

正确用法:try…catch 同步工作,只有这样才能捕获错误setTimeout(function() {try {noSuchVariable; // try…catch 处理 error 了!} catch(error) {console.log(error.name,error.message,error.stack)}}, 1000);

2022-03-17 16:05:15 733

原创 javascript类

class MyClass {prop = value; // 属性// 构造器constructor(name) {this.name = name}// methodclick = () => {alert(this.value);}get name() {return this._name} // getter 方法set name(value) {this._name = value} // setter 方法// 有计算名称(computed name)的方法

2022-03-17 11:25:39 928

原创 javascript闭包

一、闭包特性:1.不会被垃圾回收(JS GC)2.函数嵌套函数3.可以取到函数内部的私有函数和私有变量eg:function aa(){let count = 0;function add() {return count++;}return add;}let bb = aa();bb(): //0bb(): //1bb(): //2...

2022-03-17 10:19:25 519

原创 绝对定位不设置元素高宽居中的方法

父元素position:relative;子元素:position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);

2022-03-16 14:10:38 592

原创 (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node ins

这里写自定义目录标题(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild &a

2022-03-02 17:20:36 3050

原创 js中的... Rest参数与Spread语法

1.使用…复制数组、对象let arr = [1, 2, 3];let arrCopy = [...arr];let obj = { a: 1, b: 2, c: 3 };let objCopy = { ...obj };之前使用:Object.assign({}, obj)2.若 … 出现在函数参数列表的最后,那么它就是 rest 参数,它会把参数列表中剩余的参数收集到一个数组中。eg:function sumAll(...args) { // 数组名为 args let sum

2021-12-22 15:39:13 552

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除