diff --git a/pages.json b/pages.json
index f028d2f8dec54d30349881e4af8d078812f0a173..08d184b1082c6478322a625113fd8070199ebe04 100644
--- a/pages.json
+++ b/pages.json
@@ -624,6 +624,30 @@
"enablePullDownRefresh": true
}
},
+ {
+ "path": "pages/lifecycle/page/onBackPress/on-back-press-options",
+ "style": {
+ "navigationBarTitleText": "onBackPress 选项式 API"
+ }
+ },
+ {
+ "path": "pages/lifecycle/page/onBackPress/on-back-press-child-options",
+ "style": {
+ "navigationBarTitleText": "onBackPress 选项式 API"
+ }
+ },
+ {
+ "path": "pages/lifecycle/page/onBackPress/on-back-press-composition",
+ "style": {
+ "navigationBarTitleText": "onBackPress 组合式 API"
+ }
+ },
+ {
+ "path": "pages/lifecycle/page/onBackPress/on-back-press-child-composition",
+ "style": {
+ "navigationBarTitleText": "onBackPress 组合式 API"
+ }
+ },
{
"path": "pages/lifecycle/component/component-options",
"style": {
diff --git a/pages/lifecycle/page/onBackPress/on-back-press-child-composition.uvue b/pages/lifecycle/page/onBackPress/on-back-press-child-composition.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..c6fe93c9b95dc2c6bab34406af5d2bd4233d6e5e
--- /dev/null
+++ b/pages/lifecycle/page/onBackPress/on-back-press-child-composition.uvue
@@ -0,0 +1,12 @@
+
+
+ 测试 onBackPress 生命周期返回 false
+
+
+
+
\ No newline at end of file
diff --git a/pages/lifecycle/page/onBackPress/on-back-press-child-options.uvue b/pages/lifecycle/page/onBackPress/on-back-press-child-options.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..d0a35994fddabebccee0b10b47aef77bc79a02e5
--- /dev/null
+++ b/pages/lifecycle/page/onBackPress/on-back-press-child-options.uvue
@@ -0,0 +1,14 @@
+
+
+ 测试 onBackPress 生命周期返回 false
+
+
+
+
\ No newline at end of file
diff --git a/pages/lifecycle/page/onBackPress/on-back-press-composition.uvue b/pages/lifecycle/page/onBackPress/on-back-press-composition.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..c32c5eef44be88aa026e1158fb1475b2867abbba
--- /dev/null
+++ b/pages/lifecycle/page/onBackPress/on-back-press-composition.uvue
@@ -0,0 +1,28 @@
+
+
+ 测试 onBackPress 生命周期返回 true
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/lifecycle/page/onBackPress/on-back-press-options.uvue b/pages/lifecycle/page/onBackPress/on-back-press-options.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..5887ae6ae05781103e9ed42741e4093bc90a1b16
--- /dev/null
+++ b/pages/lifecycle/page/onBackPress/on-back-press-options.uvue
@@ -0,0 +1,30 @@
+
+
+ 测试 onBackPress 生命周期返回 true
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/lifecycle/page/onBackPress/on-back-press.test.js b/pages/lifecycle/page/onBackPress/on-back-press.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..49e9c95cd279e6222bacaca3ca7da8dc89f9a058
--- /dev/null
+++ b/pages/lifecycle/page/onBackPress/on-back-press.test.js
@@ -0,0 +1,34 @@
+jest.setTimeout(30000)
+const OPTIONS_PAGE_PATH = '/pages/lifecycle/page/onBackPress/on-back-press-options'
+const OPTIONS_CHILD_PAGE_PATH = '/pages/lifecycle/page/onBackPress/on-back-press-child-options'
+const COMPOSITION_PAGE_PATH = '/pages/lifecycle/page/onBackPress/on-back-press-composition'
+const COMPOSITION_CHILD_PAGE_PATH = '/pages/lifecycle/page/onBackPress/on-back-press-child-composition'
+
+describe('onBackPress 返回值', () => {
+ const test = async (pagePath, childPagePath) => {
+ const page = await program.navigateTo(pagePath)
+ await page.waitFor('view')
+ expect(page.path).toBe(pagePath.substring(1))
+ await page.callMethod('goChildPage')
+ await page.waitFor(800)
+ const childPage = await program.currentPage()
+ await childPage.waitFor('view')
+ expect(childPage.path).toBe(childPagePath.substring(1))
+ await program.navigateBack()
+ let currentPage = await program.currentPage()
+ expect(currentPage.path).toBe(pagePath.substring(1))
+ await program.navigateBack()
+ currentPage = await program.currentPage()
+ expect(currentPage.path).toBe(pagePath.substring(1))
+ const currentPageData = await currentPage.data('backPressOptions')
+ expect(currentPageData.from).toBe('navigateBack')
+
+ }
+ it('onBackPress options API', async () => {
+ await test(OPTIONS_PAGE_PATH, OPTIONS_CHILD_PAGE_PATH)
+ })
+
+ it('onBackPress composition API', async () => {
+ await test(COMPOSITION_PAGE_PATH, COMPOSITION_CHILD_PAGE_PATH)
+ })
+});
\ No newline at end of file
diff --git a/pages/lifecycle/page/page-composition.uvue b/pages/lifecycle/page/page-composition.uvue
index 7193dac002724f4a529cdb2eaba0b98195e432f8..3455ef9276e15765b58bf148fbf13a8943c6d8ba 100644
--- a/pages/lifecycle/page/page-composition.uvue
+++ b/pages/lifecycle/page/page-composition.uvue
@@ -35,14 +35,17 @@
onResize 触发:
{{ isOnResizeTriggered }}
-
-
-
+
+
+
+
@@ -50,7 +53,7 @@