标签:tostring 基本数据 const red color 默认 ons undefined span
***********
************
// 基本数据类型 const num: number = 111; const str: string = ‘shasng‘; const bool: boolean = true; const define: undefined = undefined; // 引用数据类型 const arr: number[] = [1, 2, 4]; //元组 Tuple const tupleArr: [string, number, boolean] = [‘shang‘,1, true]; // 枚举 // enum Color {Red, Green, Blue} // let c: Color = Color.Green; enum Color {Red = 1, Green, Blue} let colorName: string = Color[2]; // Any let n: any = 1235; n.toFixed(2); let t: Object = 1235; t.toString(); const arr1: any[] = [1,"shsghhg", false] // 默认情况下null和undefined是所有类型的子类型。 就是说你可以把 null和undefined赋值给number类型的变量。 //类型断言 const x: any = [1,2,3]; const len: number = (x as string).length;
标签:tostring 基本数据 const red color 默认 ons undefined span
原文地址:https://www.cnblogs.com/shangyueyue/p/10325814.html