上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 25 下一页

2025年2月18日

协变、逆变、双向协变

摘要: interface a { name: string } interface b { name: string, age: number } let A:a = { name: '222' } let B:b = { name: '112', age: 88 } // 协变,a作为主类型,b是作为副 阅读全文

posted @ 2025-02-18 17:07 ChoZ 阅读(26) 评论(0) 推荐(0)

typeof、is

摘要: // 收缩类型:判断是不是属于某个类型 // 使用typeof只对基础类型有效 // const isNum = (num:any) => typeof num 'number' // 使用instanceof可以对引用类型进行区分 const isArrary = (arr:any) => arr 阅读全文

posted @ 2025-02-18 15:26 ChoZ 阅读(11) 评论(0) 推荐(0)

Proxy、Reflect

摘要: // Proxy是es6新增的拦截器,总共拦截十三种,代理 // Reflect是反射,跟Proxy的方法一样是十三种,对应的参数一模一样 // Proxy是代理引用类型,对象、数组、map、set、函数 let person = {name:'bai',age:14} const personPr 阅读全文

posted @ 2025-02-18 13:47 ChoZ 阅读(59) 评论(0) 推荐(0)

set、map、weakSet、weakMap

摘要: // set:天然去重属性,引用类型除外 const s:Set<number> = new Set([1,2,2,3]) // console.log(s); //1,2,3 s.add(4) // 添加 s.delete(1) // 删除 s.has(2) // 判断是否有2 s.clear() 阅读全文

posted @ 2025-02-18 12:14 ChoZ 阅读(42) 评论(0) 推荐(0)

2025年2月17日

发布订阅模式

摘要: // 发布订阅模式设计模式:跟eventListener思想一样 // 监听器 // function eventFn() { // console.log('e'); // } // document.addEventListener('eee',eventFn) // // 订阅中心 // co 阅读全文

posted @ 2025-02-17 22:08 ChoZ 阅读(41) 评论(0) 推荐(0)

wepcka:从0搭建ts+vue+wepack以及插件、公共部分、样式分包

摘要: 1.构建tsconfig.json tsc --init // tsc需要全局按照typescript工具 2.构建package.json npm init -y 3.创建webpack.config.js文件 4.创建index.html,写html基本配置 5.创建src目录,依次创建App. 阅读全文

posted @ 2025-02-17 20:46 ChoZ 阅读(81) 评论(0) 推荐(0)

Decorator

摘要: // 要使用装饰器,需要在tsconfig.json中开启 "experimentalDecorators": true, "emitDecoratorMetadata": true // 装饰器就是给对应的类、属性、参数、方法添加前置的功能 import axios from "axios"; / 阅读全文

posted @ 2025-02-17 14:30 ChoZ 阅读(39) 评论(0) 推荐(0)

函数柯里化

摘要: 函数柯里化(Currying) 是一种将多个参数的函数转换为一系列使用一个参数的函数的技术。它通过将一个接收多个参数的函数转化为一系列接收一个参数的函数来逐步处理。 函数柯里化的基本概念: 假设有一个函数 f(a, b, c),柯里化后的形式是 f(a)(b)(c),即每个参数逐一传入,而不是一次性 阅读全文

posted @ 2025-02-17 12:08 ChoZ 阅读(360) 评论(0) 推荐(0)

2025年2月16日

mixins

摘要: // 对象的混入 type A = { name: string } type B = { age: number } const a9:A = { name: 'xiaobai' } const b9:B = { age: 15 } // 使用扩展运算符此时c9的类型推断 // { // name 阅读全文

posted @ 2025-02-16 17:34 ChoZ 阅读(26) 评论(0) 推荐(0)

declare module

摘要: // index.d.ts文件是描述该插件如何使用的说明,如果插件缺失该文件import时候会报错 import Axios from 'axios' // 不会报错,通过ctrl+点击会进去该index.d.ts文件 // express缺失index.d.ts直接import会报错 // 方法1 阅读全文

posted @ 2025-02-16 16:54 ChoZ 阅读(106) 评论(0) 推荐(0)

上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 25 下一页

导航