提交 ea590254 编写于 作者: M matchzhou

示例文档符号整改

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