提交 ea590254 编写于 作者: M matchzhou

示例文档符号整改

Signed-off-by: Nmatchzhou <zhouqingfeng2@huawei.com>
上级 1c73b150
......@@ -65,9 +65,9 @@ stop()
@Entry
@Component
struct Second {
@State accumulateTime: number = 0;
@State accumulateTime: number = 0
// 导入对象
controller: TextClockController = new TextClockController();
controller: TextClockController = new TextClockController()
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Current milliseconds is ' + this.accumulateTime)
......@@ -76,7 +76,7 @@ struct Second {
TextClock({ timeZoneOffset: -8, controller: this.controller })
.format('hms')
.onDateChange((value: number) => {
this.accumulateTime = value;
this.accumulateTime = value
})
.margin(20)
.fontSize(30)
......@@ -84,12 +84,12 @@ struct Second {
.margin({ bottom: 10 })
.onClick(() => {
// 启动文本时钟
this.controller.start();
this.controller.start()
})
Button("stop TextClock")
.onClick(() => {
// 停止文本时钟
this.controller.stop();
this.controller.stop()
})
}
.width('100%')
......
......@@ -61,8 +61,8 @@
@Entry
@Component
struct BadgeExample {
@State counts: number = 1;
@State message: string = 'new';
@State counts: number = 1
@State message: string = 'new'
build() {
Column() {
......@@ -77,7 +77,7 @@ struct BadgeExample {
}) {
Button('message')
.onClick(() => {
this.counts++;
this.counts++
})
.width(100).height(50).backgroundColor(0x317aff)
}.width(100).height(50)
......@@ -91,7 +91,7 @@ struct BadgeExample {
}) {
Button('message')
.onClick(() => {
this.counts++;
this.counts++
})
.width(100).height(50).backgroundColor(0x317aff)
}.width(100).height(50)
......@@ -106,7 +106,7 @@ struct BadgeExample {
}) {
Button('message')
.onClick(() => {
this.counts++;
this.counts++
})
.width(100).height(50).backgroundColor(0x317aff)
}.width(100).height(50)
......
......@@ -49,21 +49,21 @@ Navigator(value?: {target: string, type?: NavigationType})
@Entry
@Component
struct NavigatorExample {
@State active: boolean = false;
@State active: boolean = false
@State Text: object = {name: 'news'}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
Navigator({ target: 'pages/container/navigator/Detail', type: NavigationType.Push }) {
Text('Go to ' + this.Text['name'] + ' page')
.width('100%').textAlign(TextAlign.Center)
.width('100%').textAlign(TextAlign.Center)
}.params({ text: this.Text }) // 传参数到Detail页面
Navigator() {
Text('Back to previous page').width('100%').textAlign(TextAlign.Center)
}.active(this.active)
.onClick(() => {
this.active = true;
this.active = true
})
}.height(150).width(350).padding(35)
}
......@@ -78,7 +78,7 @@ import router from '@ohos.router'
@Component
struct DetailExample {
// 接收Navigator.ets的传参
@State text: any = router.getParams().text;
@State text: any = router.getParams().text
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
......@@ -87,7 +87,7 @@ struct DetailExample {
}
Text('This is ' + this.text['name'] + ' page')
.width('100%').textAlign(TextAlign.Center)
.width('100%').textAlign(TextAlign.Center)
}
.width('100%').height(200).padding({ left: 35, right: 35, top: 35 })
}
......
......@@ -49,7 +49,7 @@ struct Index {
.bindContextMenu(this.MenuBuilder, ResponseType.LongPress)
.onDragStart(()=>{
// 拖拽时关闭菜单
ContextMenu.close();
ContextMenu.close()
})
}
.width('100%')
......
......@@ -126,19 +126,19 @@ sendMouseEvent(event: MouseEvent): boolean
```ts
// xxx.ets
class Utils {
static rect_left;
static rect_top;
static rect_right;
static rect_bottom;
static rect_value;
static rect_left
static rect_top
static rect_right
static rect_bottom
static rect_value
//获取组件所占矩形区域坐标
static getComponentRect(key) {
let strJson = getInspectorByKey(key);
let obj = JSON.parse(strJson);
console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj));
let strJson = getInspectorByKey(key)
let obj = JSON.parse(strJson)
console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj))
let rectInfo = JSON.parse('[' + obj.$rect + ']')
console.info("[getInspectorByKey] rectInfo is: " + rectInfo);
console.info("[getInspectorByKey] rectInfo is: " + rectInfo)
this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0]
this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1]
this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0]
......
......@@ -22,7 +22,7 @@
@Entry
@Component
struct AspectRatioExample {
private children: string[] = ['1', '2', '3', '4', '5', '6'];
private children: string[] = ['1', '2', '3', '4', '5', '6']
build() {
Column({ space: 20 }) {
......
......@@ -84,7 +84,7 @@ struct PopupExample {
secondaryButton: {
value: 'cancel',
action: () => {
this.handlePopup = !this.handlePopup;
this.handlePopup = !this.handlePopup
console.info('cancel Button click')
}
},
......
......@@ -40,7 +40,7 @@
@Entry
@Component
struct TouchTargetExample {
@State text: string = "";
@State text: string = ""
build() {
Column({ space: 20 }) {
......@@ -49,7 +49,7 @@ struct TouchTargetExample {
Button("button1")
.responseRegion({ x: 0, y: 0, width: '50%', height: '100%' })
.onClick(() => {
this.text = 'button1 clicked';
this.text = 'button1 clicked'
})
// 热区宽度为按钮的一半,且右移一个按钮宽度,点击button2右侧左边,点击事件生效
......@@ -57,14 +57,14 @@ struct TouchTargetExample {
Button("button2")
.responseRegion({ x: '100%', y: 0, width: '50%', height: '100%' })
.onClick(() => {
this.text = 'button2 clicked';
this.text = 'button2 clicked'
})
// 热区大小为整个按钮,且下移一个按钮高度,点击button3下方按钮大小区域,点击事件生效
Text("{x:0,y:'100%',width:'100%',height:'100%'}")
Button("button3")
.responseRegion({ x: 0, y: '100%', width: '100%', height: '100%' })
.onClick(() => {
this.text = 'button3 clicked';
this.text = 'button3 clicked'
})
Text(this.text).margin({ top: 50 })
......
......@@ -24,9 +24,9 @@
@Entry
@Component
struct FocusEventExample {
@State oneButtonColor: string = '#FFC0CB';
@State twoButtonColor: string = '#87CEFA';
@State threeButtonColor: string = '#90EE90';
@State oneButtonColor: string = '#FFC0CB'
@State twoButtonColor: string = '#87CEFA'
@State threeButtonColor: string = '#90EE90'
build() {
Column({ space: 20 }) {
......@@ -38,10 +38,10 @@ struct FocusEventExample {
.fontColor(Color.Black)
.focusable(true)
.onFocus(() => {
this.oneButtonColor = '#FF0000';
this.oneButtonColor = '#FF0000'
})
.onBlur(() => {
this.oneButtonColor = '#FFC0CB';
this.oneButtonColor = '#FFC0CB'
})
Button('Second Button')
.backgroundColor(this.twoButtonColor)
......@@ -50,10 +50,10 @@ struct FocusEventExample {
.fontColor(Color.Black)
.focusable(true)
.onFocus(() => {
this.twoButtonColor = '#FF0000';
this.twoButtonColor = '#FF0000'
})
.onBlur(() => {
this.twoButtonColor = '#87CEFA';
this.twoButtonColor = '#87CEFA'
})
Button('Third Button')
.backgroundColor(this.threeButtonColor)
......@@ -62,10 +62,10 @@ struct FocusEventExample {
.fontColor(Color.Black)
.focusable(true)
.onFocus(() => {
this.threeButtonColor = '#FF0000';
this.threeButtonColor = '#FF0000'
})
.onBlur(() => {
this.threeButtonColor = '#90EE90';
this.threeButtonColor = '#90EE90'
})
}.width('100%').margin({ top: 20 })
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册