diff --git a/pages/lifecycle/component/component-composition.test.js b/pages/lifecycle/component/component-composition.test.js
index 586be2a9b63e1e33e499e14bc1acdee4ed8ed022..d6059e27250459b3bd151793d66c42f430f840ce 100644
--- a/pages/lifecycle/component/component-composition.test.js
+++ b/pages/lifecycle/component/component-composition.test.js
@@ -40,8 +40,8 @@ describe('component-lifecycle', () => {
await toggleAliveComponentBtn.tap()
lifeCycleNum = await page.callMethod('pageGetLifeCycleNum')
- // TODO: android 端 keep-alive 组件切换时,不触发 activated, 会触发 beforeUpdate updated
- expect(lifeCycleNum).toBe(isAndroid ? 114 : 113)
+ // TODO: android 端 组合式 API 不触发 activated
+ expect(lifeCycleNum).toBe(isAndroid ? 112 : 113)
await page.callMethod('pageSetLifeCycleNum', 0)
})
it('onBeforeUpdate onUpdated', async () => {
diff --git a/pages/lifecycle/component/component-composition.uvue b/pages/lifecycle/component/component-composition.uvue
index 5dfd68d18bc20a42458b01dd7ac6a553aeef133b..416172c8bfa0fe2443038c9f4a37741695709725 100644
--- a/pages/lifecycle/component/component-composition.uvue
+++ b/pages/lifecycle/component/component-composition.uvue
@@ -7,8 +7,9 @@
-
+
+
@@ -61,6 +62,12 @@
// 自动化测试
const getIsScrolled = () : boolean => {
return isScrolled.value
+ }
+
+ const navigateToHome = () => {
+ uni.navigateTo({
+ url: '/pages/index/index'
+ })
}
defineExpose({
diff --git a/pages/lifecycle/component/component-options.test.js b/pages/lifecycle/component/component-options.test.js
index 00d5f2f6b416ebbc6083a1061180706967c4adef..cc8f6189dcc75aef8583e073308269752c19401f 100644
--- a/pages/lifecycle/component/component-options.test.js
+++ b/pages/lifecycle/component/component-options.test.js
@@ -4,8 +4,6 @@ const HOME_PATH = '/pages/index/index'
describe('component-lifecycle', () => {
let page
let lifeCycleNum
- const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
- const isAndroid = platformInfo.includes('android')
beforeAll(async () => {
page = await program.reLaunch(HOME_PATH)
await page.waitFor(700)
@@ -33,20 +31,19 @@ describe('component-lifecycle', () => {
await toggleAliveComponentBtn.tap()
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(4)
- // TODO: android 端 keep-alive 组件切换时,不仅触发 activated, 之前还会触发 beforeUpdate updated
await toggleAliveComponentBtn.tap()
lifeCycleNum = await page.callMethod('getLifeCycleNum')
- expect(lifeCycleNum).toBe(isAndroid ? 7 : 5)
+ expect(lifeCycleNum).toBe(5)
})
it('beforeUpdate updated', async () => {
const updateTitleBtn = await page.$('.component-lifecycle-btn')
await updateTitleBtn.tap()
lifeCycleNum = await page.callMethod('getLifeCycleNum')
- expect(lifeCycleNum).toBe(isAndroid ? 9 : 7)
+ expect(lifeCycleNum).toBe(7)
})
it('deactivated beforeUnmount unmounted', async () => {
page = await program.navigateBack()
lifeCycleNum = await page.callMethod('getLifeCycleNum')
- expect(lifeCycleNum).toBe(isAndroid ? 6 : 4)
+ expect(lifeCycleNum).toBe(4)
})
})
\ No newline at end of file
diff --git a/pages/lifecycle/component/component-options.uvue b/pages/lifecycle/component/component-options.uvue
index 7673f3341d18b97ea04253f528c2cb293f8e7705..c5b97377165795bd4441a78686306ded817b8e5e 100644
--- a/pages/lifecycle/component/component-options.uvue
+++ b/pages/lifecycle/component/component-options.uvue
@@ -4,7 +4,8 @@
-
+
+
@@ -26,6 +27,11 @@ export default {
},
toggleAliveComponent(){
this.aliveComponent = this.aliveComponent == null ? ChildComponent : null
+ },
+ navigateToHome() {
+ uni.navigateTo({
+ url: '/pages/index/index'
+ })
}
},
}