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

2025年2月14日

type

摘要: // ts自带类型推论,此时推论为string,要修改类型推论的话就自定义类型 let str = '456' // str = 456 // 赋值数字会报错 let str1 // 不定义会自动推论为any // type可以自定义名称,指定各种类型 type a = {} type b = [] 阅读全文

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

枚举

摘要: // 数字枚举 // 自增值 // enum e { // red, // green, // black // } // console.log(e.red,e.green,e.black); // 0,1,2 // 可以设置默认值,没定义的还是会默认自增 // enum e { // red, 阅读全文

posted @ 2025-02-14 13:14 ChoZ 阅读(3) 评论(0) 推荐(0)

元组

摘要: // 元组 const arr:[string, boolean, number] = ['123', false, 123] arr.push(456) // console.log(arr[3]) // 元组越界之后,虽然可以push,但是实际上访问不到,arr[3]报错 // arr.push 阅读全文

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

abstract

摘要: // abstract 抽象类不能实例化,抽象方法不能具体的定义 abstract class Vue { constructor(parameters) { } // 报错 // abstract init() {} abstract init(name:string) :void after() 阅读全文

posted @ 2025-02-14 11:51 ChoZ 阅读(3) 评论(0) 推荐(0)

2025年2月13日

class

摘要: interface Options { el: string | HTMLElement } interface VueCls { options: Options init: () => void } interface VNode { tag: string // div session tex 阅读全文

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

2025年2月12日

ecma、dom、bom

摘要: // js内置对象类型 // ecma let num:Number = new Number(1) let data:Date = new Date() let err:Error = new Error('错误') let reg:RegExp = new RegExp(/\w/) let xm 阅读全文

posted @ 2025-02-12 21:49 ChoZ 阅读(7) 评论(0) 推荐(0)

混合类型| 、交叉类型& 、断言as

摘要: // 联合类型 |, 代表可以传字符串或者数字 // const a = (name: string | number) => { // console.log(name); // } // a('gg') // a(18) // 交叉类型 &, 代表需要满足2个interface // inter 阅读全文

posted @ 2025-02-12 16:55 ChoZ 阅读(3) 评论(0) 推荐(0)

function

摘要: // 基础使用和箭头函数 // function add(a:number, b:number):number { // return a+b // } // const muti = (a:number, b:number):number => a*b // 参数默认传值、函数可选参数 // co 阅读全文

posted @ 2025-02-12 15:57 ChoZ 阅读(3) 评论(0) 推荐(0)

数组

摘要: // 基础用法:type[] let arr:number[] = [1,2,3] // 泛型用法:Arrary<type> let arr1:Array<boolean> = [true,true] // interface用法: interface[] interface x { name: s 阅读全文

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

interface

摘要: // interface 常用于约束定义返回的数据,interface中定义了,则使用该interface的变量不可以多一个或者少一个 // interface res { // name: string // 不需要逗号隔行 // value: number // } // let result: 阅读全文

posted @ 2025-02-12 11:50 ChoZ 阅读(3) 评论(0) 推荐(0)

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

导航