about.vue
2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<template>
<div />
</template>
<script setup lang="ts">
// 类装饰器、方法装饰器、属性装饰器、参数装饰器
// function addAge(constructor: Function) {
// constructor.prototype.age = 18
// }
// @addAge
// class Person {
// name: string;
// age!: number;
// constructor() {
// this.name = 'abc'
// }
// say () {
// console.warn('xxx')
// }
// }
// let person = new Person();
// console.warn(person);
// 属性/方法装饰器
// 声明装饰器修饰方法
// function method(target: any, propertyKey: string, descriptor: PropertyDescriptor) {
// console.warn(target);
// console.warn('prop ' + propertyKey);
// console.warn('desc ' + JSON.stringify(descriptor));
// descriptor.writable = false;
// }
// // 声明装饰器修饰属性
// function prop(target: any, key: string): any {
// console.warn(target);
// console.warn('prop ' + key);
// const descriptor: PropertyDescriptor = {
// writable: true,
// configurable: true,
// enumerable: true,
// value: 'abc'
// };
// return descriptor;
// }
// // 类
// class Person {
// // @prop
// name: string;
// constructor() {
// this.name = 'xxx'
// }
// @method
// say() {
// return 'instance method'
// }
// @method
// static run() {
// return 'static method'
// }
// }
// const person = new Person()
// person.name
// Person.run()
// 参数装饰器
// function logParameter(target: Object, propertyKey: string, index: number) {
// console.log(target, propertyKey, index);
// }
// class Person {
// greet(@logParameter message: string, @logParameter name: string): string {
// return `${message} ${name}`;
// }
// }
// const p = new Person('');
// p.greet('hello', 'randy');
// class Person {
// name = 'abc'
// constructor (name) {
// this.name = name;
// }
// say() {
// console.warn('');
// }
// }
// import Person from '@/Person'
// class Son extends Person {
// say () {
// return ''
// }
// }
// const person = new Son('')
// console.warn(person);
// type E3 = NonNullable<string | number | null | undefined>
// // let e1: E3 = 1
// let e2: E3 = undefined
// console.warn(e2);
// function getUserInfo () {
// return 'abc'
// }
// type E = ReturnType<typeof getUserInfo>
// const user: E = {}
// console.warn(user);
// interface A {
// a: string;
// b: number;
// d: boolean;
// }
// type aPartial = Partial<A>
// type Point = 'x';
// type PointList = Record<Point, { key: number }>
// const z: PointList = {
// x: {
// key: 1
// }
// }
</script>
<style lang="less" scoped>
</style>