let title:string='helld' console.log('我说',title)
let age:number=8 console.log('我说',age)
let isLogin:boolean=true console.log('我说',isLogin)
let num:string[]=['aa','ss','sw'] console.log('ww',num)
function star(){ console.log('ss','@@') console.log('ss','@@') console.log('ss','@@') } star()
//定义接口 interface ps{ name:string weight:number age:number } //基于接口定义对象 let ym:ps={ name:'哑巴分泌', weight:34, age:12 } //获取对象的属性值 对象名。属性值 console.log(')',ym.name)
//定义接口 interface ps{ name:string weight:number age:number sing:(song:string)=>void dance:()=>void } //基于接口定义对象 let ym:ps={ name:'哑巴分泌', weight:34, age:12, sing:(song:string)=>{ console.log('ss','ssss',song) }, dance:()=>{ console.log("sssss",'qqqq') } } //获取对象的属性值 对象名。属性值 ym.sing("sss") ym.dance()
let yu:number | string =100
enum yy { Red='#ff0f29', Orange='#ff7100' } let color:yy =yy.Red
界面开发
@Entry @Component struct Index { @State message: string = '啥地方'; build() { RelativeContainer() { Text(this.message) .id('HelloWorld') .fontSize(50) .fontWeight(FontWeight.Bold) .fontColor(Color.Blue) .alignRules({ center: { anchor: '__container__', align: VerticalAlign.Center }, middle: { anchor: '__container__', align: HorizontalAlign.Center } }) } .height('100%') .width('100%') } }
@Entry @Component struct Index { @State message: string = '啥地方'; build() { Column(){ Text('小说简介') .width('100%') .height(40) .fontSize(20) .fontWeight(FontWeight.Bold) Row(){ Text('都市') .width(50) .height(30) .backgroundColor(Color.Orange) Text('生活') .width(50) .height(30) .backgroundColor(Color.Orange) Text('情感') .width(50) .height(30) .backgroundColor(Color.Orange) Text('男频') .width(50) .height(30) .backgroundColor(Color.Orange) } .width('100%') } .width('100%') } }
@Entry @Component struct Index { @State message: string = '啥地方'; build() { Column(){ Text('我爱学习,我爱中国') .width('100%') .height(40) .fontSize(24) Row(){ Text('置顶 ') .fontColor('#df3c50') Text('新华社 ') .fontColor('#a1a1a1') Text('1086评论') .fontColor('#a1a1a1') } .width('100%') } .width('100%') } }
@Entry @Component struct Index { @State message: string = '啥地方'; build() { Column(){ Text('我在家,家在哪') .width('100%') .fontSize(20) .fontWeight(FontWeight.Bold) Text('拦截 28608.recommend_list.baidu.com常见颜色十六进制代码 啊啊啊啊啊啊啊啊啊文啊啊啊啊啊啊啊啊啊啊啊啊啊文啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊') .width('100%') .lineHeight(24) .textOverflow({ overflow:TextOverflow.Ellipsis }) .maxLines(2) } .width('100%') } }
@Entry @Component struct Index { @State message: string = '啥地方'; build() { Column() { Image('https://k.sinaimg.cn/n/sinakd20240916s/290/w1080h810/20240916/78b4-c9372aa67be3954ac0aa4c8e55278d2e.jpg/w700d1q75cms.jpg?by=cms_fixed_width') .height(70) } } }
@Entry @Component struct Index { @State message: string = '啥地方'; build() { Column() { Image($r('app.media.background')) .width(200) Text('龙年打击') .width(200) Row(){ Image($r('app.media.startIcon')) .width(20) Text('代码哥') } .width(200) } } }
@Entry @Component struct Index { @State message: string = '啥地方'; build() { Column({space:15}){ TextInput({ placeholder:'qingshutu' }) TextInput({ placeholder:'qqqqqqq' }).type(InputType.Password) Button('ss') .width(200) } } }
@Entry @Component struct Index { @State message: string = '啥地方'; build() { Column({space:15}){ Image($r('app.media.startIcon')) .width(50) TextInput({ placeholder:'qqq' }) TextInput({ placeholder:'www' }).type(InputType.Password) Button('ee') .width('100%') Row({space:15}) { Text('qqqq') Text('www') } } .width('100%') .padding(20) } }