上一页 1 ··· 3 4 5 6 7 8 9 10 下一页
摘要: 侦测变化 - watch Watch 文档地址 // watch 简单应用 watch(data, () => { document.title = 'updated ' + data.count }) // watch 的两个参数,代表新的值和旧的值 watch(refData.count, (n 阅读全文
posted @ 2021-02-26 16:59 `Duet` 阅读(954) 评论(0) 推荐(0) 编辑
摘要: Vue3 生命周期 生命周期 在 setup 中使用的 hook 名称和原来生命周期的对应关系 beforeCreate → 不需要 created → 不需要 beforeMount → onBeforeMount mounted → onMounted beforeUpdate → onBefo 阅读全文
posted @ 2021-02-26 14:33 `Duet` 阅读(199) 评论(0) 推荐(0) 编辑
摘要: Reactive 函数 Reactive 函数 import { ref, computed, reactive, toRefs } from 'vue' interface DataProps { count: number; double: number; increase: () => voi 阅读全文
posted @ 2021-02-25 20:49 `Duet` 阅读(614) 评论(0) 推荐(0) 编辑
摘要: Ref 语法 setup 方法 ref 函数 <template> <h1>{{count}}</h1> <h1>{{double}}</h1> <button @click="increase">+1</button> </template> import { ref } from "vue" s 阅读全文
posted @ 2021-02-25 20:26 `Duet` 阅读(1642) 评论(0) 推荐(0) 编辑
摘要: 项目结构和插件 Eslint 插件 如果 eslint 不生效,可以在根目录创建 .vscode 文件夹,然后在文件夹中创建 settings.json 然后输入 { "eslint.validate": [ "typescript" ] } Vetur 插件 阅读全文
posted @ 2021-02-25 14:31 `Duet` 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 配置 vue3 开发环境 Vue cli // 安装或者升级 npm install -g @vue/cli # OR yarn global add @vue/cli // 保证 vue cli 版本在 4.5.0 以上 vue --version // 创建项目 vue create my-pr 阅读全文
posted @ 2021-02-24 11:51 `Duet` 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 内置类型 内置类型 const a: Array<number> = [1,2,3] // 大家可以看到这个类型,不同的文件中有多处定义,但是它们都是 内部定义的一部分,然后根据不同的版本或者功能合并在了一起,一个interface 或者 类多次定义会合并在一起。这些文件一般都是以 lib 开头,以 阅读全文
posted @ 2021-02-23 21:19 `Duet` 阅读(280) 评论(0) 推荐(0) 编辑
摘要: 类型别名 和 交叉类型 类型别名 Type Aliases 类型别名,就是给类型起一个别名,让它可以更方便的被重用。 let sum: (x: number, y: number) => number const result = sum(1,2) type PlusType = (x: numbe 阅读全文
posted @ 2021-02-23 18:34 `Duet` 阅读(54) 评论(0) 推荐(0) 编辑
摘要: 泛型第三部分 - 泛型与类和接口 class Queue { private data = []; push(item) { return this.data.push(item) } pop() { return this.data.shift() } } const queue = new Qu 阅读全文
posted @ 2021-02-22 14:55 `Duet` 阅读(48) 评论(0) 推荐(0) 编辑
摘要: 泛型第二部分 - 泛型约束 在函数内部使用泛型变量的时候,由于事先不知道它是哪种类型,所以不能随意的操作它的属性或方法 function echoWithArr<T>(arg: T): T { console.log(arg.length) return arg } // 上例中,泛型 T 不一定包 阅读全文
posted @ 2021-02-22 12:02 `Duet` 阅读(54) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 下一页