1.1.1 • Published 5 years ago
ts-annotation v1.1.1
typescript annotation
目录
安装
$ npm install ts-annotation
介绍
ts-annotation
用typescript写的装饰器(注解), 当前typescript的版本号为3.4.3.
使用
代码在 /test/index.ts
class Test {
// 100ms内最多渲染一次
@Debounce(100)
render() {}
// 处理前
@Before()
getData() {}
// 处理
@Around()
dealData() {}
处理后
@After()
showData() {}
// 防抖
@Leading(100)
fetch() {}
// 去除两边的空格,可以对对象使用
@Validate
show(@Trim message) {}
// 移除所有null undefined ''
@Validata
show(@RemoveEmpty message) {}
}
注意
需要安装tsc
使用Around
注解默认是异步的,所以需要注意用async
await
或者promise