diff --git a/layout/CommonLayout/entry/src/main/ets/common/constants/Const.ets b/layout/CommonLayout/entry/src/main/ets/common/constants/Const.ets index 44a406f0d89ad671d2b07e34622b6f41ed2c5836..3f089ef4fa5f67fdc95f715a8f733d1c48edcc58 100644 --- a/layout/CommonLayout/entry/src/main/ets/common/constants/Const.ets +++ b/layout/CommonLayout/entry/src/main/ets/common/constants/Const.ets @@ -5,6 +5,7 @@ const Const = { Index: "pages/Index", HEADER: "pages/header/Header", FOOTER: "pages/footer/Footer", + COMMON_LAYOUT: "pages/commonLayout/CommonLayout", } } diff --git a/layout/CommonLayout/entry/src/main/ets/pages/Index.ets b/layout/CommonLayout/entry/src/main/ets/pages/Index.ets index 383f125b0a390cb17cfaf56427a8e4dee0420416..edcd578ac0df66d0a04506aec828a07c1d49c329 100644 --- a/layout/CommonLayout/entry/src/main/ets/pages/Index.ets +++ b/layout/CommonLayout/entry/src/main/ets/pages/Index.ets @@ -26,6 +26,13 @@ struct Index { url: Const.RouterPath.FOOTER }) }) + Button("CommonLayout") + .width(CommonConstant.COMMON_WIDTH) + .onClick(() => { + router.pushUrl({ + url: Const.RouterPath.COMMON_LAYOUT + }) + }) } .width('100%') } diff --git a/layout/CommonLayout/entry/src/main/ets/pages/commonLayout/CommonLayout.ets b/layout/CommonLayout/entry/src/main/ets/pages/commonLayout/CommonLayout.ets new file mode 100644 index 0000000000000000000000000000000000000000..22de153b738ba753e9eee720c5c6ed160d1e0056 --- /dev/null +++ b/layout/CommonLayout/entry/src/main/ets/pages/commonLayout/CommonLayout.ets @@ -0,0 +1,34 @@ +import CommonConstant from '../../common/constants/CommonConstant' +import NavigationBar from '../../components/NavigationBar' + +@Entry +@Component +struct CommonLayout { + @State message: string = 'Hello World' + + build() { + Column() { + NavigationBar({ title: "通用布局" }) + Grid() { + GridItem() { + Button("login") + } + GridItem() { + Button("login") + } + GridItem() { + Button("login") + } + GridItem() { + Button("login") + } + } + .columnsTemplate('1fr 1fr 1fr') + .rowsGap(10) + .columnsGap(10) + .width(CommonConstant.COMMON_WIDTH) + } + .width('100%') + .backgroundColor(0xFAEEE0) + } +} \ No newline at end of file diff --git a/layout/CommonLayout/entry/src/main/resources/base/profile/main_pages.json b/layout/CommonLayout/entry/src/main/resources/base/profile/main_pages.json index bc9c608ab9bc9c41564378cfdd849088e3c50035..a2598f51ff46a687e8cb9c23686c32c7aa23f4af 100644 --- a/layout/CommonLayout/entry/src/main/resources/base/profile/main_pages.json +++ b/layout/CommonLayout/entry/src/main/resources/base/profile/main_pages.json @@ -2,6 +2,7 @@ "src": [ "pages/Index", "pages/header/Header", - "pages/footer/Footer" + "pages/footer/Footer", + "pages/commonLayout/CommonLayout" ] } \ No newline at end of file