Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
46665ec9
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
400
Star
3
Fork
10
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello-uvue
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
46665ec9
编写于
4月 16, 2024
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(lifecycle-page): 已新增 composition,但是需要修改测试用例
上级
f8466b31
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
243 addition
and
102 deletion
+243
-102
pages.json
pages.json
+9
-2
pages/index/index.uvue
pages/index/index.uvue
+26
-2
pages/lifecycle/page/page-composition.uvue
pages/lifecycle/page/page-composition.uvue
+110
-0
pages/lifecycle/page/page-options.uvue
pages/lifecycle/page/page-options.uvue
+97
-0
pages/lifecycle/page/page.test.js
pages/lifecycle/page/page.test.js
+1
-1
pages/lifecycle/page/page.uvue
pages/lifecycle/page/page.uvue
+0
-97
未找到文件。
pages.json
浏览文件 @
46665ec9
...
...
@@ -271,9 +271,16 @@
}
},
{
"path"
:
"pages/lifecycle/page/page"
,
"path"
:
"pages/lifecycle/page/page
-composition
"
,
"style"
:
{
"navigationBarTitleText"
:
"page-lifecycle"
,
"navigationBarTitleText"
:
"page-lifecycle(组合式)"
,
"enablePullDownRefresh"
:
true
}
},
{
"path"
:
"pages/lifecycle/page/page-options"
,
"style"
:
{
"navigationBarTitleText"
:
"page-lifecycle(选项式)"
,
"enablePullDownRefresh"
:
true
}
},
...
...
pages/index/index.uvue
浏览文件 @
46665ec9
...
...
@@ -113,7 +113,8 @@ export default {
]
}
] as Page[],
},{
},
{
id: 'component-instance',
name: '组件 实例',
pages: [
...
...
@@ -227,7 +228,30 @@ export default {
},
// #endif
] as Page[],
}
},
{
id: 'lifecycle',
name: '生命周期',
pages: [
{
id: 'page',
name: '页面生命周期',
children: [
{
id: 'page-options',
name: '页面生命周期(选项式)',
url: 'page-options',
},
{
id: 'page-composition',
name: '页面生命周期(组合式)',
url: 'page-composition',
}
]
}
] as Page[]
}
] as Menu[],
}
},
...
...
pages/lifecycle/page/page-composition.uvue
0 → 100644
浏览文件 @
46665ec9
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1" :bounces="false">
<!-- #endif -->
<view class="page container">
<text>page lifecycle</text>
<button class="uni-common-mt" @click="scrollToBottom">scrollToBottom</button>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts'
const isScrolled = ref<boolean>(false)
onLoad((_ : OnLoadOptions) => {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 100)
})
onUnload(() => {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 100)
})
onReady(() => {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
})
onPageShow(() => {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
})
onPageHide(() => {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 10)
})
onPageScroll((_) => {
// 自动化测试
isScrolled.value = true
})
onPullDownRefresh(() => {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
})
onReachBottom(() => {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
})
onBackPress((_ : OnBackPressOptions) : boolean | null => {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 10)
return null
})
onResize((_ : OnResizeOptions) => {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
})
// 自动化测试
const getLifeCycleNum = () : number => {
return state.lifeCycleNum
}
// 自动化测试
const setLifeCycleNum = (num : number) => {
setLifeCycleNum(num)
}
// 自动化测试
const pullDownRefresh = () => {
uni.startPullDownRefresh({
success() {
setTimeout(() => {
uni.stopPullDownRefresh()
// 一秒后立即停止下拉刷新不会触发 onPullDownRefresh,因为下拉动画时间大概需要1.1~1.2秒
}, 1500)
},
})
}
const scrollToBottom = () => {
uni.pageScrollTo({
scrollTop: 2000,
})
}
defineExpose({
getLifeCycleNum,
setLifeCycleNum,
pullDownRefresh,
scrollToBottom
})
</script>
<style>
.container {
height: 1200px;
}
</style>
\ No newline at end of file
pages/lifecycle/page/page-options.uvue
0 → 100644
浏览文件 @
46665ec9
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1" :bounces="false">
<!-- #endif -->
<view class="page container">
<text>page lifecycle</text>
<button class="uni-common-mt" @click="scrollToBottom">scrollToBottom</button>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts'
export default {
data() {
return {
isScrolled: false,
}
},
onLoad(_ : OnLoadOptions) {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 100)
},
onShow() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
onReady() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
onPullDownRefresh() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
onPageScroll(_) {
// 自动化测试
this.isScrolled = true
},
onReachBottom() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
onBackPress(_ : OnBackPressOptions) : boolean | null {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 10)
return null
},
onHide() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 10)
},
onUnload() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 100)
},
onResize(_) {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
methods: {
// 自动化测试
getLifeCycleNum() : number {
return state.lifeCycleNum
},
// 自动化测试
setLifeCycleNum(num : number) {
setLifeCycleNum(num)
},
// 自动化测试
pullDownRefresh() {
uni.startPullDownRefresh({
success() {
setTimeout(() => {
uni.stopPullDownRefresh()
// 一秒后立即停止下拉刷新不会触发 onPullDownRefresh,因为下拉动画时间大概需要1.1~1.2秒
}, 1500)
},
})
},
scrollToBottom() {
uni.pageScrollTo({
scrollTop: 2000,
})
},
},
}
</script>
<style>
.container {
height: 1200px;
}
</style>
\ No newline at end of file
pages/lifecycle/page/page.test.js
浏览文件 @
46665ec9
const
PAGE_PATH
=
'
/pages/lifecycle/page/page
'
const
PAGE_PATH
=
'
/pages/lifecycle/page/page
-options
'
const
HOME_PATH
=
'
/pages/tab-bar/options-api
'
const
INTER_PAGE_PATH
=
'
/pages/app-instance/index/index
'
let
page
...
...
pages/lifecycle/page/page.uvue
已删除
100644 → 0
浏览文件 @
f8466b31
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1" :bounces="false">
<!-- #endif -->
<view class="page container">
<text>page lifecycle</text>
<button class="uni-common-mt" @click="scrollToBottom">scrollToBottom</button>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts'
export default {
data() {
return {
isScrolled: false,
}
},
onLoad(_ : OnLoadOptions) {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 100)
},
onShow() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
onReady() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
onPullDownRefresh() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
onPageScroll(_) {
// 自动化测试
this.isScrolled = true
},
onReachBottom() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
onBackPress(_ : OnBackPressOptions) : boolean | null {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 10)
return null
},
onHide() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 10)
},
onUnload() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 100)
},
onResize(_){
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
methods: {
// 自动化测试
getLifeCycleNum() : number {
return state.lifeCycleNum
},
// 自动化测试
setLifeCycleNum(num : number) {
setLifeCycleNum(num)
},
// 自动化测试
pullDownRefresh() {
uni.startPullDownRefresh({
success() {
setTimeout(() => {
uni.stopPullDownRefresh()
// 一秒后立即停止下拉刷新不会触发 onPullDownRefresh,因为下拉动画时间大概需要1.1~1.2秒
}, 1500)
},
})
},
scrollToBottom() {
uni.pageScrollTo({
scrollTop: 2000,
})
},
},
}
</script>
<style>
.container {
height: 1200px;
}
</style>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录