Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
75d07614
U
uni-app
项目概览
DCloud
/
uni-app
2 个月 前同步成功
通知
717
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
75d07614
编写于
11月 19, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(h5): onLoad
上级
2e1f2ac1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
15 addition
and
6 deletion
+15
-6
packages/uni-h5/src/framework/setup/index.ts
packages/uni-h5/src/framework/setup/index.ts
+15
-6
未找到文件。
packages/uni-h5/src/framework/setup/index.ts
浏览文件 @
75d07614
...
...
@@ -33,13 +33,17 @@ import { initLaunchOptions, getEnterOptions } from './utils'
interface
SetupComponentOptions
{
init
:
(
vm
:
ComponentPublicInstance
)
=>
void
setup
:
(
instance
:
ComponentInternalInstance
)
=>
Record
<
string
,
any
>
|
void
setup
:
(
instance
:
ComponentInternalInstance
)
=>
Record
<
string
,
unknown
>
|
void
afterSetup
?:
(
instance
:
ComponentInternalInstance
,
query
:
Record
<
string
,
unknown
>
)
=>
void
before
?:
(
comp
:
DefineComponent
)
=>
void
}
function
wrapperComponentSetup
(
comp
:
DefineComponent
,
{
init
,
setup
,
before
}:
SetupComponentOptions
{
init
,
setup
,
before
,
afterSetup
}:
SetupComponentOptions
)
{
before
&&
before
(
comp
)
const
oldSetup
=
comp
.
setup
...
...
@@ -50,6 +54,9 @@ function wrapperComponentSetup(
if
(
oldSetup
)
{
return
oldSetup
(
query
||
props
,
ctx
)
}
if
(
afterSetup
)
{
afterSetup
(
instance
,
query
!
)
}
}
}
...
...
@@ -78,6 +85,11 @@ export function setupWindow(comp: any, id: number) {
export
function
setupPage
(
comp
:
any
)
{
return
setupComponent
(
comp
,
{
init
:
initPage
,
afterSetup
(
instance
,
query
)
{
// 因为 onLoad 是在 setup 执行过程中添加的,故需要放在 after 中执行
const
{
onLoad
}
=
instance
onLoad
&&
invokeArrayFns
(
onLoad
,
decodedQuery
(
query
))
},
setup
(
instance
)
{
instance
.
root
=
instance
// 组件 root 指向页面
const
route
=
usePageRoute
()
...
...
@@ -89,12 +101,9 @@ export function setupPage(comp: any) {
})
return
route
.
query
}
const
pageMeta
=
usePageMeta
()
// 放在 onMounted 中,可以保证子组件中监听的相关生命周期也可以触发,比如onShow,onPageScroll
const
{
onLoad
}
=
instance
onLoad
&&
invokeArrayFns
(
onLoad
,
decodedQuery
(
route
.
query
))
onMounted
(()
=>
{
// 放在 onMounted 中,可以保证子组件中监听的相关生命周期也可以触发,比如onShow,onPageScroll
onPageShow
(
instance
,
pageMeta
)
const
{
onShow
}
=
instance
instance
.
__isVisible
=
true
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录