Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
01fe3047
U
uni-app
项目概览
DCloud
/
uni-app
6 个月 前同步成功
通知
751
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
01fe3047
编写于
11月 16, 2023
作者:
朱
朱立行
提交者:
折腾笔记
2月 02, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(uni-mp-xhs): page首次进入onShow没有调用
上级
b2f341cd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
172 addition
and
170 deletion
+172
-170
packages/uni-mp-xhs/dist/index.js
packages/uni-mp-xhs/dist/index.js
+74
-73
src/platforms/mp-xhs/runtime/wrapper/page-parser.js
src/platforms/mp-xhs/runtime/wrapper/page-parser.js
+98
-97
未找到文件。
packages/uni-mp-xhs/dist/index.js
浏览文件 @
01fe3047
...
...
@@ -2232,79 +2232,80 @@ const handleWrap = function (mp, destory) {
});
};
const
hooks$1
=
[
'
onShow
'
,
'
onHide
'
,
'
onUnload
'
];
hooks$1
.
push
(...
PAGE_EVENT_HOOKS
);
function
parsePage
(
vuePageOptions
)
{
const
[
VueComponent
,
vueOptions
]
=
initVueComponent
(
Vue
,
vuePageOptions
);
const
pageOptions
=
{
mixins
:
initBehaviors
(
vueOptions
,
initBehavior
),
data
:
initData
(
vueOptions
,
Vue
.
prototype
),
onLoad
(
query
)
{
const
properties
=
this
.
props
;
this
.
__query
=
query
;
this
.
__options
=
{
mpType
:
'
page
'
,
mpInstance
:
this
,
propsData
:
properties
};
},
onReady
()
{
// initChildVues(this)
// 初始化 vue 实例
this
.
$vm
=
new
VueComponent
(
this
.
__options
);
// 触发首次 setData
this
.
$vm
.
$mount
();
initSpecialMethods
(
this
);
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
);
// mounted => onLoad
this
.
options
=
this
.
__query
;
this
.
$vm
.
$mp
.
query
=
this
.
__query
;
// 兼容 mpvue
const
copyQuery
=
Object
.
assign
({},
this
.
__query
);
delete
copyQuery
.
__id__
;
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
copyQuery
)
};
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
this
.
__query
);
setTimeout
(()
=>
{
this
.
$vm
.
__call_hook
(
'
onReady
'
);
});
},
onUnload
()
{
this
.
$vm
.
__call_hook
(
'
onUnload
'
);
this
.
$vm
.
$destroy
();
},
// __r: handleRef,
__e
:
handleEvent
,
__l
:
handleLink
,
__w
:
handleWrap
,
triggerEvent
:
function
noop
()
{}
};
initHooks
(
pageOptions
,
hooks$1
,
vueOptions
);
initUnknownHooks
(
pageOptions
,
vueOptions
,
[
'
onReady
'
]);
if
(
Array
.
isArray
(
vueOptions
.
wxsCallMethods
))
{
vueOptions
.
wxsCallMethods
.
forEach
(
callMethod
=>
{
pageOptions
[
callMethod
]
=
function
(
args
)
{
return
this
.
$vm
[
callMethod
](
args
)
};
});
}
return
pageOptions
const
hooks$1
=
[
'
onShow
'
,
'
onHide
'
,
'
onUnload
'
];
hooks$1
.
push
(...
PAGE_EVENT_HOOKS
);
function
parsePage
(
vuePageOptions
)
{
const
[
VueComponent
,
vueOptions
]
=
initVueComponent
(
Vue
,
vuePageOptions
);
const
pageOptions
=
{
mixins
:
initBehaviors
(
vueOptions
,
initBehavior
),
data
:
initData
(
vueOptions
,
Vue
.
prototype
),
onLoad
(
query
)
{
const
properties
=
this
.
props
;
this
.
__query
=
query
;
this
.
__options
=
{
mpType
:
'
page
'
,
mpInstance
:
this
,
propsData
:
properties
};
},
onReady
()
{
// initChildVues(this)
// 初始化 vue 实例
this
.
$vm
=
new
VueComponent
(
this
.
__options
);
// 触发首次 setData
this
.
$vm
.
$mount
();
initSpecialMethods
(
this
);
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
);
// mounted => onLoad
this
.
options
=
this
.
__query
;
this
.
$vm
.
$mp
.
query
=
this
.
__query
;
// 兼容 mpvue
const
copyQuery
=
Object
.
assign
({},
this
.
__query
);
delete
copyQuery
.
__id__
;
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
copyQuery
)
};
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
this
.
__query
);
this
.
$vm
.
__call_hook
(
'
onShow
'
);
setTimeout
(()
=>
{
this
.
$vm
.
__call_hook
(
'
onReady
'
);
});
},
onUnload
()
{
this
.
$vm
.
__call_hook
(
'
onUnload
'
);
this
.
$vm
.
$destroy
();
},
// __r: handleRef,
__e
:
handleEvent
,
__l
:
handleLink
,
__w
:
handleWrap
,
triggerEvent
:
function
noop
()
{}
};
initHooks
(
pageOptions
,
hooks$1
,
vueOptions
);
initUnknownHooks
(
pageOptions
,
vueOptions
,
[
'
onReady
'
]);
if
(
Array
.
isArray
(
vueOptions
.
wxsCallMethods
))
{
vueOptions
.
wxsCallMethods
.
forEach
(
callMethod
=>
{
pageOptions
[
callMethod
]
=
function
(
args
)
{
return
this
.
$vm
[
callMethod
](
args
)
};
});
}
return
pageOptions
}
function
createPage
(
vuePageOptions
)
{
...
...
src/platforms/mp-xhs/runtime/wrapper/page-parser.js
浏览文件 @
01fe3047
import
Vue
from
'
vue
'
import
{
stringifyQuery
}
from
'
uni-shared/query
'
import
{
initData
,
initHooks
,
initUnknownHooks
,
handleEvent
,
initBehaviors
,
initVueComponent
,
PAGE_EVENT_HOOKS
}
from
'
uni-wrapper/util
'
import
{
handleLink
,
initBehavior
}
from
'
../../../mp-weixin/runtime/wrapper/util
'
import
{
handleWrap
,
initSpecialMethods
}
from
'
./util
'
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onUnload
'
]
hooks
.
push
(...
PAGE_EVENT_HOOKS
)
export
default
function
parsePage
(
vuePageOptions
)
{
const
[
VueComponent
,
vueOptions
]
=
initVueComponent
(
Vue
,
vuePageOptions
)
const
pageOptions
=
{
mixins
:
initBehaviors
(
vueOptions
,
initBehavior
),
data
:
initData
(
vueOptions
,
Vue
.
prototype
),
onLoad
(
query
)
{
const
properties
=
this
.
props
this
.
__query
=
query
this
.
__options
=
{
mpType
:
'
page
'
,
mpInstance
:
this
,
propsData
:
properties
}
},
onReady
()
{
// initChildVues(this)
// 初始化 vue 实例
this
.
$vm
=
new
VueComponent
(
this
.
__options
)
// 触发首次 setData
this
.
$vm
.
$mount
()
initSpecialMethods
(
this
)
this
.
$vm
.
_isMounted
=
true
this
.
$vm
.
__call_hook
(
'
mounted
'
)
// mounted => onLoad
this
.
options
=
this
.
__query
this
.
$vm
.
$mp
.
query
=
this
.
__query
// 兼容 mpvue
const
copyQuery
=
Object
.
assign
({},
this
.
__query
)
delete
copyQuery
.
__id__
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
copyQuery
)
}
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
this
.
__query
)
setTimeout
(()
=>
{
this
.
$vm
.
__call_hook
(
'
onReady
'
)
})
},
onUnload
()
{
this
.
$vm
.
__call_hook
(
'
onUnload
'
)
this
.
$vm
.
$destroy
()
},
// __r: handleRef,
__e
:
handleEvent
,
__l
:
handleLink
,
__w
:
handleWrap
,
triggerEvent
:
function
noop
()
{}
}
initHooks
(
pageOptions
,
hooks
,
vueOptions
)
initUnknownHooks
(
pageOptions
,
vueOptions
,
[
'
onReady
'
])
if
(
Array
.
isArray
(
vueOptions
.
wxsCallMethods
))
{
vueOptions
.
wxsCallMethods
.
forEach
(
callMethod
=>
{
pageOptions
[
callMethod
]
=
function
(
args
)
{
return
this
.
$vm
[
callMethod
](
args
)
}
})
}
return
pageOptions
}
import
Vue
from
'
vue
'
import
{
stringifyQuery
}
from
'
uni-shared/query
'
import
{
initData
,
initHooks
,
initUnknownHooks
,
handleEvent
,
initBehaviors
,
initVueComponent
,
PAGE_EVENT_HOOKS
}
from
'
uni-wrapper/util
'
import
{
handleLink
,
initBehavior
}
from
'
../../../mp-weixin/runtime/wrapper/util
'
import
{
handleWrap
,
initSpecialMethods
}
from
'
./util
'
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onUnload
'
]
hooks
.
push
(...
PAGE_EVENT_HOOKS
)
export
default
function
parsePage
(
vuePageOptions
)
{
const
[
VueComponent
,
vueOptions
]
=
initVueComponent
(
Vue
,
vuePageOptions
)
const
pageOptions
=
{
mixins
:
initBehaviors
(
vueOptions
,
initBehavior
),
data
:
initData
(
vueOptions
,
Vue
.
prototype
),
onLoad
(
query
)
{
const
properties
=
this
.
props
this
.
__query
=
query
this
.
__options
=
{
mpType
:
'
page
'
,
mpInstance
:
this
,
propsData
:
properties
}
},
onReady
()
{
// initChildVues(this)
// 初始化 vue 实例
this
.
$vm
=
new
VueComponent
(
this
.
__options
)
// 触发首次 setData
this
.
$vm
.
$mount
()
initSpecialMethods
(
this
)
this
.
$vm
.
_isMounted
=
true
this
.
$vm
.
__call_hook
(
'
mounted
'
)
// mounted => onLoad
this
.
options
=
this
.
__query
this
.
$vm
.
$mp
.
query
=
this
.
__query
// 兼容 mpvue
const
copyQuery
=
Object
.
assign
({},
this
.
__query
)
delete
copyQuery
.
__id__
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
copyQuery
)
}
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
this
.
__query
)
this
.
$vm
.
__call_hook
(
'
onShow
'
)
setTimeout
(()
=>
{
this
.
$vm
.
__call_hook
(
'
onReady
'
)
})
},
onUnload
()
{
this
.
$vm
.
__call_hook
(
'
onUnload
'
)
this
.
$vm
.
$destroy
()
},
// __r: handleRef,
__e
:
handleEvent
,
__l
:
handleLink
,
__w
:
handleWrap
,
triggerEvent
:
function
noop
()
{}
}
initHooks
(
pageOptions
,
hooks
,
vueOptions
)
initUnknownHooks
(
pageOptions
,
vueOptions
,
[
'
onReady
'
])
if
(
Array
.
isArray
(
vueOptions
.
wxsCallMethods
))
{
vueOptions
.
wxsCallMethods
.
forEach
(
callMethod
=>
{
pageOptions
[
callMethod
]
=
function
(
args
)
{
return
this
.
$vm
[
callMethod
](
args
)
}
})
}
return
pageOptions
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录