Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
d59a599d
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5992
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
d59a599d
编写于
9月 11, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(getCurrentPages): 增加针对 UniPage 示例及测试
上级
d7389302
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
118 addition
and
12 deletion
+118
-12
pages/API/get-app/get-app.uvue
pages/API/get-app/get-app.uvue
+2
-2
pages/API/get-current-pages/get-current-pages.test.js
pages/API/get-current-pages/get-current-pages.test.js
+26
-3
pages/API/get-current-pages/get-current-pages.uvue
pages/API/get-current-pages/get-current-pages.uvue
+90
-7
未找到文件。
pages/API/get-app/get-app.uvue
浏览文件 @
d59a599d
...
@@ -204,7 +204,7 @@
...
@@ -204,7 +204,7 @@
app.emit('fn3', null)
app.emit('fn3', null)
const res = num == 6
const res = num == 6
console.log('check
E
ventBus', res)
console.log('check
e
ventBus', res)
return res
return res
},
},
checkGetAndroidApplication() : boolean {
checkGetAndroidApplication() : boolean {
...
@@ -216,7 +216,7 @@
...
@@ -216,7 +216,7 @@
// #ifndef APP-ANDROID
// #ifndef APP-ANDROID
const res = androidApplication == null
const res = androidApplication == null
// #endif
// #endif
console.log('check
G
etAndroidApplication', res)
console.log('check
g
etAndroidApplication', res)
return res
return res
}
}
},
},
...
...
pages/API/get-current-pages/get-current-pages.test.js
浏览文件 @
d59a599d
const
HOME_PAGE_PATH
=
'
/pages/tabBar/component
'
const
HOME_PAGE_PATH
=
'
/pages/tabBar/component
'
const
PAGE_PATH
=
'
/pages/API/get-current-pages/get-current-pages
'
const
PAGE_PATH
=
'
/pages/API/get-current-pages/get-current-pages
?test=123
'
describe
(
'
getCurrentPages
'
,
()
=>
{
describe
(
'
getCurrentPages
'
,
()
=>
{
let
page
let
page
...
@@ -25,8 +25,6 @@ describe('getCurrentPages', () => {
...
@@ -25,8 +25,6 @@ describe('getCurrentPages', () => {
expect
(
data
.
checked
).
toBe
(
true
)
expect
(
data
.
checked
).
toBe
(
true
)
})
})
it
(
'
page-style
'
,
async
()
=>
{
it
(
'
page-style
'
,
async
()
=>
{
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
callMethod
(
'
getPageStyle
'
)
await
page
.
callMethod
(
'
getPageStyle
'
)
await
page
.
waitFor
(
200
)
await
page
.
waitFor
(
200
)
const
isEnablePullDownRefresh1
=
(
await
page
.
data
()).
currentPageStyle
.
enablePullDownRefresh
const
isEnablePullDownRefresh1
=
(
await
page
.
data
()).
currentPageStyle
.
enablePullDownRefresh
...
@@ -63,4 +61,29 @@ describe('getCurrentPages', () => {
...
@@ -63,4 +61,29 @@ describe('getCurrentPages', () => {
return
'
get-current-pages-test-js-get-current-pages-page-style-after-set-page-style
'
return
'
get-current-pages-test-js-get-current-pages-page-style-after-set-page-style
'
}});
}});
})
})
it
(
'
$page
'
,
async
()
=>
{
await
page
.
setData
({
testing
:
true
})
const
res
=
await
page
.
callMethod
(
'
check$page
'
)
expect
(
res
).
toBe
(
true
)
})
it
(
'
eventBus
'
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
checkEventBus
'
)
expect
(
res
).
toBe
(
true
)
})
it
(
'
getParentPage
'
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
checkGetParentPage
'
)
expect
(
res
).
toBe
(
true
)
})
it
(
'
getDialogPages
'
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
checkGetDialogPages
'
)
expect
(
res
).
toBe
(
true
)
})
it
(
'
getElementById
'
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
checkGetElementById
'
)
expect
(
res
).
toBe
(
true
)
})
it
(
'
getAndroidView
'
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
checkGetAndroidView
'
)
expect
(
res
).
toBe
(
true
)
})
})
})
pages/API/get-current-pages/get-current-pages.uvue
浏览文件 @
d59a599d
...
@@ -12,8 +12,16 @@
...
@@ -12,8 +12,16 @@
<text style="margin-top: 5px">index: {{ index }}, route: {{ page.route }}</text>
<text style="margin-top: 5px">index: {{ index }}, route: {{ page.route }}</text>
</template>
</template>
</view>
</view>
<button class="uni-common-mt" @click="check$page">check $page</button>
<button class="uni-common-mt" @click="checkEventBus">check eventBus</button>
<button class="uni-common-mt" @click="checkGetParentPage">check getParentPage</button>
<button class="uni-common-mt" @click="checkGetDialogPages">check getDialogPages</button>
<button id="check-get-element-by-id-btn" class="uni-common-mt" @click="checkGetElementById">check
getElementById</button>
<button class="uni-common-mt" @click="checkGetAndroidView">check getAndroidView</button>
</view>
</view>
<page-head title="currentPageStyle"></page-head>
<page-head title="currentPageStyle"></page-head>
<template v-for="(item, index) in PageStyleArray">
<template v-for="(item, index) in PageStyleArray">
<view class="page-style-item" v-if="currentPageStyle[item.key]!=null" :key="index">
<view class="page-style-item" v-if="currentPageStyle[item.key]!=null" :key="index">
...
@@ -59,7 +67,8 @@
...
@@ -59,7 +67,8 @@
checked: false,
checked: false,
pages: [] as Page[],
pages: [] as Page[],
PageStyleArray: PageStyleArray as PageStyleItem[],
PageStyleArray: PageStyleArray as PageStyleItem[],
currentPageStyle: {} as UTSJSONObject,
currentPageStyle: {} as UTSJSONObject,
testing: false
}
}
},
},
computed: {
computed: {
...
@@ -125,12 +134,86 @@
...
@@ -125,12 +134,86 @@
uni.navigateTo({
uni.navigateTo({
url: '/pages/API/get-current-pages/set-page-style-disable-pull-down-refresh'
url: '/pages/API/get-current-pages/set-page-style-disable-pull-down-refresh'
});
});
}
},
// getCurrentPage(): Page {
getCurrentPage() : UniPage {
// const pages = getCurrentPages();
const pages = getCurrentPages()
// const currentPage = pages[pages.length - 1];
return pages[pages.length - 1]
// return currentPage;
},
// }
check$page() : boolean {
const page = this.getCurrentPage()
let res = this.$page === page
if(this.testing){
res = res && page.options.get('test') == '123'
}
console.log('check $page', res)
return res
},
checkEventBus() : boolean {
const page = this.getCurrentPage()
let num = 0
const fn1 = (args : any | null) => {
console.log('fn1 triggred', args)
num++
}
const fn2 = (args : any | null) => {
console.log('fn2 triggred', args)
num++
}
const fn3 = (args : any | null) => {
console.log('fn3 triggred', args)
num++
}
page.on('fn12', fn1)
page.on('fn12', fn2)
page.once('fn3', fn3)
page.emit('fn12', { name: 'name' })
page.emit('fn12', { age: 20 })
page.off('fn12', fn1)
page.emit('fn12', null)
page.emit('fn3', { name: 'name' })
page.emit('fn3', { age: 20 })
page.emit('fn3', null)
const res = num == 6
console.log('check eventBus', res)
return res
},
checkGetParentPage() : boolean {
const page = this.getCurrentPage()
const parentPage = page.getParentPage()
const res = parentPage == null
console.log('check getParentPage', res)
return res
},
checkGetDialogPages() : boolean {
const page = this.getCurrentPage()
const dialogPages = page.getDialogPages()
const res = Array.isArray(dialogPages) && dialogPages.length == 0
console.log('check getDialogPages', res)
return res
},
checkGetElementById() : boolean {
const page = this.getCurrentPage()
const element = page.getElementById('check-get-element-by-id-btn')
const res = element != null
console.log('check getElementById', res)
return res
},
checkGetAndroidView() : boolean {
const page = this.getCurrentPage()
const androidView = page.getAndroidView()
// #ifdef APP-ANDROID
const res = androidView != null
// #endif
// #ifndef APP-ANDROID
const res = androidView == null
// #endif
console.log('check getAndroidView', res)
return res
},
},
},
}
}
</script>
</script>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录