1.arkts基础
//变量的存储和修改(string number boolea)
let title:string = '字符串类型'
let num:number = 21.4
let isLogin:boolean = false
title = '字符串hhhhh'
console.log(title,isLogin,num)
//常量
const PI: number = 3.1435
console.log('pi',PI)
//数组
let names:string[] = ['liuyifei','yangmi','liushishi']
console.log('取出杨幂',names[1]);
//普通函数
function changeWether() {console.log('天气改变了');
}
changeWether()
function changeEat(food:string,water:string) {console.log(food,water)
}
changeEat('面包','苏打水')
//箭头函数
let book = () => {console.log('红色的书')
}
book()
//对象
interface Person {name:stringage:numberweight:numberdance:() => voidsing:(name:string) => void
}let xiaoxiao:Person = {name:'xiao',age:33,weight:120,dance:() => {console.log('跳舞');},sing:(singName:string) => {console.log('唱的歌曲是',singName)}
}
xiaoxiao.dance()
xiaoxiao.sing('爱的供养')
console.log(xiaoxiao.name)
//联合类型
let judge:number | string = '橘子'
console.log('judge is ',judge);
judge = 231;
console.log('judge is ',judge);
let gender:'man'|'woman'|'secret' = 'man'
//枚举类型
enum ThemeColor {Red = '#787878'Yellow = '#909090'
}
let color:ThemeColor = ThemeColor.Red