diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index aa2bbab..a745e49 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -12,6 +12,28 @@ struct Index { .onClick(() => { this.message = 'Welcome'; }) + Button() { + Text('Next') + .fontSize(30) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + .onClick(() => { + console.log("用户操作:点击按钮") + let uiContext: UIContext = this.getUIContext(); + let router = uiContext.getRouter(); + router.pushUrl({ + url: 'pages/Second' + }).then(() => { + console.log('系统提示:跳转成功') + }) + }) } .width('100%') } diff --git a/entry/src/main/ets/pages/Second.ets b/entry/src/main/ets/pages/Second.ets new file mode 100644 index 0000000..bfda83b --- /dev/null +++ b/entry/src/main/ets/pages/Second.ets @@ -0,0 +1,29 @@ +@Entry +@Component +struct Second { + @State message: string = '万物互联'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('Back') + .fontSize(30) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json index 1898d94..f6191bd 100644 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -1,5 +1,6 @@ { "src": [ - "pages/Index" + "pages/Index", + "pages/Second" ] }