上一页 1 2 3 4 5 6 ··· 19 下一页

2021年7月7日

类型兼容性

摘要: ts的类型兼容性是基于结构类型的。 结构类型是一种只使用其成员来描述类型的方式。(大白话:看属性兼容) 如果传入的变量A和声明的类型B不匹配,ts会进行兼容性检查 只要用户传入变量A中的属性>=在源类型B要求的属性,那么认为就是兼容的 interface INamed { name: string 阅读全文

posted @ 2021-07-07 16:35 章画 阅读(109) 评论(0) 推荐(0) 编辑

computed/watch/watchEffect

摘要: computed computed去计算基本数据类型 // computed去计算基本数据类型 const count=ref(1) // computed ()里面是不带任何参数的。写成函数形式要有返回值,不然默认是undefined。箭头函数一行默认就是有返回值 const plusOne=co 阅读全文

posted @ 2021-07-07 11:02 章画 阅读(180) 评论(0) 推荐(0) 编辑

2021年7月6日

ref reactive readonly

摘要: aa readonly:通过reactive/ref可以获取到一个响应式对象,但是在一些情况下我们传给其他组件这个响应式对象只能使用不能把它修改。这个时候就应该用readonly。 本质是readonly会返回原生对象的只读对象,也就是说它依然是一个proxy,但是只有set没有set或者说prox 阅读全文

posted @ 2021-07-06 18:01 章画 阅读(58) 评论(0) 推荐(0) 编辑

setup

摘要: const {aa,bb } = toRefs(props) //这样才是响应式解构props setup函数返回值 1:可以返回一个对象,对象里面的值可以在template模板里面使用 2:setup 还可以返回一个渲染函数,该函数可以直接使用在同一作用域中声明的响应式状态值。 return () 阅读全文

posted @ 2021-07-06 15:36 章画 阅读(630) 评论(0) 推荐(0) 编辑

2021年6月29日

class

摘要: 最简单的类 class Person { name: string //定义实例属性 age: number = 20 // 定义实例属性并且赋值 constructor(name: string) { this.name = name //实例属性赋值 } run(): void { consol 阅读全文

posted @ 2021-06-29 16:20 章画 阅读(187) 评论(0) 推荐(0) 编辑

type 关键字

摘要: type常用用法 type words = (word: string) => string //type 定义函数类型1 type AddtionType={(a:number,b:number):number} //type 定义函数类型2 很像接口是不是 type methodType = ' 阅读全文

posted @ 2021-06-29 13:48 章画 阅读(250) 评论(0) 推荐(0) 编辑

2021年6月25日

函数

摘要: type和interface分别用来定义函数 type GetUserNameType = (firstName: string, lastName: string) => string //type关键字用来定义一个类型 const getUser2: GetUserNameType = (fir 阅读全文

posted @ 2021-06-25 12:13 章画 阅读(20) 评论(0) 推荐(0) 编辑

泛型

摘要: 泛型:组件不仅能够支持当前的数据类型,同时也能支持未来的数据类型,用户就可以以自己的数据类型来使用组件。更加灵活 泛型接口 //泛型接口的第一种定义方式 当这个接口去限制函数,推荐使用这个 interface IPrint { <T>(value: T): T } const print: IPri 阅读全文

posted @ 2021-06-25 12:09 章画 阅读(38) 评论(0) 推荐(0) 编辑

接口

摘要: //js写代码方式 你不知道user对象需要传入什么属性 除非你写注释什么的 注释只起个提示错误却不能提示语法错误 const getUserInfo = user => { return `name:${user.name};age:${user.age}` } getUserInfo({}) / 阅读全文

posted @ 2021-06-25 12:07 章画 阅读(38) 评论(0) 推荐(0) 编辑

2021年6月19日

1很快的过基础

摘要: 绑定class/style 个人习惯:通通用函数绑定. 函数要显式执行(). // <p :class="setABClass()">{{str}} </p> --》 class="a b" setABClass(){ // return { //对象语法可以 // a:true, // b:tru 阅读全文

posted @ 2021-06-19 16:28 章画 阅读(21) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 ··· 19 下一页

导航