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

feat: getCurrentPages

上级 4b5ec577
...@@ -153,6 +153,12 @@ ...@@ -153,6 +153,12 @@
"navigationBarTitleText": "getApp" "navigationBarTitleText": "getApp"
} }
}, },
{
"path": "pages/API/get-current-pages/get-current-pages",
"style": {
"navigationBarTitleText": "getCurrentPages"
}
},
{ {
"path": "pages/API/navigator/navigator", "path": "pages/API/navigator/navigator",
"style": { "style": {
......
const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages'
describe('getCurrentPages', () => {
it('getCurrentPages', async () => {
const page = await program.navigateTo(PAGE_PATH)
await page.waitFor(1000)
await page.callMethod('getCurrentPages')
const data = await page.data()
expect(data.checked).toBe(true)
})
})
<template>
<view>
<page-head title="getCurrentPages"></page-head>
<button @click="getCurrentPages">getCurrentPages</button>
</view>
</template>
<script>
export default {
data() {
return {
checked: false,
}
},
methods: {
getCurrentPages: function () {
const pages = getCurrentPages()
if (pages[0].route.includes('/tabBar/')) {
this.checked = true
}
for (let i = 1; i < pages.length; i++) {
if (pages[i].route.includes('/tabBar/')) {
this.checked = false
}
}
},
},
}
</script>
...@@ -48,10 +48,14 @@ ...@@ -48,10 +48,14 @@
name: "基础", name: "基础",
open: false, open: false,
pages: [ pages: [
{ {
name: "getApp", name: "getApp",
url: "get-app", url: "get-app",
}, },
{
name: "getCurrentPages",
url: "get-current-pages",
},
{ {
name: "事件总线event-bus", name: "事件总线event-bus",
url: "event-bus", url: "event-bus",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册