提交 cab95603 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

test: remove page hide and show

上级 18126b9d
...@@ -13,10 +13,4 @@ describe('getCurrentPages', () => { ...@@ -13,10 +13,4 @@ describe('getCurrentPages', () => {
const data = await page.data() const data = await page.data()
expect(data.checked).toBe(true) 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)
})
}) })
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
<page-head title="getCurrentPages"></page-head> <page-head title="getCurrentPages"></page-head>
<view class="uni-padding-wrap"> <view class="uni-padding-wrap">
<button @click="_getCurrentPages">getCurrentPages</button> <button @click="_getCurrentPages">getCurrentPages</button>
<button class="uni-common-mt" @click="hideAndShow">页面隐藏并显示</button>
<view v-if="pages.length" style="padding: 15px 0px"> <view v-if="pages.length" style="padding: 15px 0px">
<text>当前页面栈中 {{ pages.length }} 个页面,列表如下:</text> <text>当前页面栈中 {{ pages.length }} 个页面,列表如下:</text>
<template v-for="(page, index) in pages" :key="page.route"> <template v-for="(page, index) in pages" :key="page.route">
...@@ -18,45 +17,32 @@ ...@@ -18,45 +17,32 @@
<script lang="uts"> <script lang="uts">
class Page { class Page {
constructor(public route : string) { constructor(public route : string) {
} }
} }
export default { export default {
data() { data() {
return { return {
checked: false, checked: false,
showTimes: 0, pages: [] as Page[],
pages: [] as Page[], }
} },
}, methods: {
onShow() { _getCurrentPages: function () {
this.showTimes++ this.pages.length = 0
}, const pages = getCurrentPages()
methods: { this.pages.push(new Page(pages[0].route))
_getCurrentPages: function () { if (this.pages[0].route.includes('/tabBar/')) {
this.pages.length = 0 this.checked = true
const pages = getCurrentPages() }
this.pages.push(new Page(pages[0].route)) for (let i = 1; i < pages.length; i++) {
if (this.pages[0].route.includes('/tabBar/')) { this.pages.push(new Page(pages[i].route))
this.checked = true if (pages[i].route.includes('/tabBar/')) {
} this.checked = false
for (let i = 1; i < pages.length; i++) { }
this.pages.push(new Page(pages[i].route)) }
if (pages[i].route.includes('/tabBar/')) { },
this.checked = false },
}
}
},
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())
}
}
},
} }
</script> </script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册