From dc8319920690ff8014a88b74db026722dfb872f3 Mon Sep 17 00:00:00 2001
From: zhenyuWang <13641039885@163.com>
Date: Wed, 19 Jul 2023 13:30:08 +0800
Subject: [PATCH] feat: getCurrentPages
---
.../get-current-pages.test.js | 11 ++-
.../get-current-pages/get-current-pages.uvue | 83 ++++++++++++-------
2 files changed, 61 insertions(+), 33 deletions(-)
diff --git a/pages/API/get-current-pages/get-current-pages.test.js b/pages/API/get-current-pages/get-current-pages.test.js
index f380eeca..7a90aa7d 100644
--- a/pages/API/get-current-pages/get-current-pages.test.js
+++ b/pages/API/get-current-pages/get-current-pages.test.js
@@ -1,11 +1,18 @@
const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages'
describe('getCurrentPages', () => {
+ let page
it('getCurrentPages', async () => {
- const page = await program.navigateTo(PAGE_PATH)
+ page = await program.navigateTo(PAGE_PATH)
await page.waitFor(1000)
- await page.callMethod('getCurrentPages')
+ await page.callMethod('_getCurrentPages')
const data = await page.data()
expect(data.checked).toBe(true)
})
+ it('hideAndShow', async () => {
+ await page.callMethod('hideAndShow')
+ await page.waitFor(1000)
+ const data = await page.data()
+ expect(data.showTimes).toBe(2)
+ })
})
diff --git a/pages/API/get-current-pages/get-current-pages.uvue b/pages/API/get-current-pages/get-current-pages.uvue
index 509b20b3..a921881d 100644
--- a/pages/API/get-current-pages/get-current-pages.uvue
+++ b/pages/API/get-current-pages/get-current-pages.uvue
@@ -1,37 +1,58 @@
-
-
-
- {{result}}
-
+
+
+
+
+
+ 当前页面栈中 {{pages.length}} 个页面,列表如下:
+
+ index: {{ index }}, route: {{ page.route }}
+
+
+
\ No newline at end of file
+ hideAndShow() {
+ const pages = getCurrentPages()
+ const currentPage = pages[pages.length - 1]
+ const currentPageInstance = currentPage.$getAppPage()
+ if (currentPageInstance != null) {
+ currentPageInstance.hide(new Map())
+ currentPageInstance.show(new Map())
+ }
+ }
+ },
+}
+
--
GitLab