Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
a7d9aa1d
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6005
Star
91
Fork
164
代码
文件
提交
分支
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看板
提交
a7d9aa1d
编写于
7月 20, 2023
作者:
taohebin@dcloud.io
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://gitcode.net/dcloud/hello-uni-app-x
上级
4f1c2664
82f99ff6
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
123 addition
and
31 deletion
+123
-31
App.vue
App.vue
+7
-0
pages/API/get-app/get-app.test.js
pages/API/get-app/get-app.test.js
+4
-3
pages/API/get-app/get-app.uvue
pages/API/get-app/get-app.uvue
+26
-18
pages/API/get-current-pages/get-current-pages.uvue
pages/API/get-current-pages/get-current-pages.uvue
+11
-9
pages/API/navigator/navigator.test.js
pages/API/navigator/navigator.test.js
+30
-0
pages/API/navigator/navigator.uvue
pages/API/navigator/navigator.uvue
+45
-0
pages/tabBar/API.uvue
pages/tabBar/API.uvue
+0
-1
未找到文件。
App.vue
浏览文件 @
a7d9aa1d
...
...
@@ -32,8 +32,15 @@ export default {
onLastPageBackPress
:
function
():
boolean
|
null
{
// 自动化测试
setLifeCycleNum
(
state
.
lifeCycleNum
-
1000
)
console
.
log
(
'
App LastPageBackPress
'
)
return
null
},
methods
:
{
increasetLifeCycleNum
()
{
setLifeCycleNum
(
state
.
lifeCycleNum
+
100
)
console
.
log
(
'
App increasetLifeCycleNum
'
)
}
}
}
</
script
>
...
...
pages/API/get-app/get-app.test.js
浏览文件 @
a7d9aa1d
...
...
@@ -4,8 +4,9 @@ describe('getApp', () => {
it
(
'
getApp
'
,
async
()
=>
{
const
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
waitFor
(
1000
)
await
page
.
callMethod
(
'
_getApp
'
)
const
data
=
await
page
.
data
()
expect
(
data
.
checked
).
toBe
(
true
)
const
oldData
=
await
page
.
data
()
await
page
.
callMethod
(
'
_increasetLifeCycleNum
'
)
const
newData
=
await
page
.
data
()
expect
(
newData
.
lifeCycleNum
-
oldData
.
lifeCycleNum
).
toBe
(
100
)
})
})
pages/API/get-app/get-app.uvue
浏览文件 @
a7d9aa1d
<template>
<view>
<page-head title="getApp"></page-head>
<button @click="_getApp">getApp</button>
<view class="uni-padding-wrap">
<button @click="_increasetLifeCycleNum">increase lifeCycleNum</button>
<text class="uni-common-mt">lifeCycleNum: {{ lifeCycleNum }}</text>
</view>
</view>
</template>
<script>
export default {
<script lang="ts">
import { state } from '@/store/index.uts'
export default {
data() {
return {
checked: false
lifeCycleNum: 0,
}
},
onReady() {
this.lifeCycleNum = state.lifeCycleNum
},
methods: {
_getApp: function () {
// const app = getApp()
this.checked = true
}
}
}
_increasetLifeCycleNum: function () {
const app = getApp()
app.increasetLifeCycleNum()
this.lifeCycleNum = state.lifeCycleNum
},
},
}
</script>
pages/API/get-current-pages/get-current-pages.uvue
浏览文件 @
a7d9aa1d
<template>
<view>
<page-head title="getCurrentPages"></page-head>
<view class="uni-padding-wrap">
<button @click="_getCurrentPages">getCurrentPages</button>
<button class="uni-common-mt" @click="hideAndShow">页面隐藏并显示</button>
<view style="padding: 15px 1
0px">
<text>当前页面栈中 {{pages.length
}} 个页面,列表如下:</text>
<view style="padding: 15px
0px">
<text>当前页面栈中 {{ pages.length
}} 个页面,列表如下:</text>
<template v-for="(page, index) in pages" :key="page.route">
<text style="margin-top: 5px"
>index: {{ index }}, route: {{ page.route }}</text
...
...
@@ -12,6 +13,7 @@
</template>
</view>
</view>
</view>
</template>
<script>
class Page {
...
...
pages/API/navigator/navigator.test.js
浏览文件 @
a7d9aa1d
...
...
@@ -51,6 +51,36 @@ describe('navigator', () => {
await
page
.
waitFor
(
1000
)
})
it
(
'
navigateTo relative path
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
await
page
.
callMethod
(
'
navigateToRelativePath1
'
)
page
=
await
program
.
navigateBack
()
await
page
.
waitFor
(
1000
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
2
)
await
page
.
waitFor
(
1000
)
})
it
(
'
navigateTo relative path ./
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
await
page
.
callMethod
(
'
navigateToRelativePath2
'
)
page
=
await
program
.
navigateBack
()
await
page
.
waitFor
(
1000
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
2
)
await
page
.
waitFor
(
1000
)
})
it
(
'
navigateTo relative path ../
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
await
page
.
callMethod
(
'
navigateToRelativePath3
'
)
page
=
await
program
.
navigateBack
()
await
page
.
waitFor
(
1000
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
2
)
await
page
.
waitFor
(
1000
)
})
it
(
'
navigateBack
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
await
page
.
callMethod
(
'
navigateBack
'
)
...
...
pages/API/navigator/navigator.uvue
浏览文件 @
a7d9aa1d
...
...
@@ -175,6 +175,51 @@ export default {
},
})
},
// 自动化测试
navigateToRelativePath1() {
uni.navigateTo({
url: 'new-page/new-page-1?data=new-page/new-page-1',
success() {
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail() {
setLifeCycleNum(state.lifeCycleNum - 1)
},
complete() {
setLifeCycleNum(state.lifeCycleNum + 1)
},
})
},
// 自动化测试
navigateToRelativePath2() {
uni.navigateTo({
url: './new-page/new-page-1?data=./new-page/new-page-1',
success() {
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail() {
setLifeCycleNum(state.lifeCycleNum - 1)
},
complete() {
setLifeCycleNum(state.lifeCycleNum + 1)
},
})
},
// 自动化测试
navigateToRelativePath3() {
uni.navigateTo({
url: '../navigator/new-page/new-page-1?data=../navigator/new-page/new-page-1',
success() {
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail() {
setLifeCycleNum(state.lifeCycleNum - 1)
},
complete() {
setLifeCycleNum(state.lifeCycleNum + 1)
},
})
},
navigateBack() {
uni.navigateBack({
success(result) {
...
...
pages/tabBar/API.uvue
浏览文件 @
a7d9aa1d
...
...
@@ -51,7 +51,6 @@
{
name: "getApp",
url: "get-app",
enable: false
},
{
name: "getCurrentPages",
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录