TS(typescript)
ts是微软推出的静态类型的语言
相比于js,ts拥有强类型、编译器严谨的语法检查、更加严苛的语法
typescript > ES6 > javascript
运行的时候,ts 编译成javascript
ts默认文件后缀名.ts
在ts中定义变量(vue3下的setup中)
//字符串
const str1 = ref<string>("abc")
const str2 = ref("abc") //根据值类型自动判断改类型变量是什么
//数字
const num1= ref<number>(10)
const num2= ref(10)
//布尔值
const boolean1 = ref<boolen>(true)
const boolean2 = ref(true)
//函数
function add(n1:string,n2:number):void{}
//对象
interface Iuser {
name: string,
age: number,
pet: undefined | string
} //定义接口
const list = reactive<Iuser>({ name: "zhoumao", age: 18, pet: "dog" })
//数组
const array: Array<any> = [1, 2, 3, '我爱我的祖国'];