1.js装饰器啥意思 https://xw.qq.com/cmsid/20200324A0LOFE00 就相当于java里的那些@override @request啥的标注
ts中使用vue里的computed https://blog.csdn.net/weixin_45614615/article/details/112057767
2.vue中使用ts https://www.cnblogs.com/yf-html/p/13723268.html
3.Typescript中的as关键字比如this as any 啥意思
https://www.cnblogs.com/gloryhope/p/13637371.html 就是说你虽然定义的是number,但是我规定这里以string编译它
4.关于泛型 function<T>
https://www.tslang.cn/docs/handbook/generics.html这个讲的很清楚了,什么是泛型,为什么要泛型,为什么不用any
泛型类的作用 https://blog.csdn.net/mrxao/article/details/52789368
5.vscode中如何运行ts
https://blog.uproject.cn/articles/2020/07/19/1595140643483.html
6.关于ts中的函数前的问号 ?
http://www.5imoban.net/jiaocheng/jquery/202102014694.html
function f(x: number, y?: number) {
console.log(y)
return x + (y || 0);
}
console.log(f(1, 2))
console.log(f(1))
console.log(f(1, undefined))
console.log(f(1, null)) // error, 'null' is not assignable to 'number | undefined'
// 2
// 3
// undefined
// 1
// undefined
// 1
// null
// 1
7.今天在公司写vue+ts的项目,发现有几个地方比较特别
01.如果函数中后面的代码出现this.a.b,只要出现两个以上的.,那么就需要在开头定义这么一句,const self = this as any,不然会报类型错误, 意思这样,后面的类型都可以any吗?
02.定义的data都要写类型,而这些类型都要小写,其中数组不是写array,会报错 应该这么写 list:object[] = [] 这个表示定义一个数组,里面的类型是object类型
https://blog.csdn.net/weixin_41229588/article/details/95354067 还可以 boolean[] =[false,true] number[] =[1,2]等等
03.vue中ts的写法,基本是每个的js部分都是用类...很像react,需要什么computed,或者watch,都需要import 从那个s类导入,其中 computed的用法 是这样 需要加一个 get前缀在函数前面,就是computed
8.watch深度监听对象,不深度监听对象的 话,对象属性更新不会不触发,监听不到
@Watch('isComParamShow', { deep: true })
watchComParamShow(newVal: object, oldVal: object) {
const self = this as any;
this.$nextTick(() => {
self.$refs.multipleTable.clearSelection();
})
}