Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
e135ea3d
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,发现更多精彩内容 >>
提交
e135ea3d
编写于
3月 07, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(h5): lifecycle
上级
ce1aeb57
变更
12
展开全部
隐藏空白更改
内联
并排
Showing
12 changed file
with
59 addition
and
31 deletion
+59
-31
packages/uni-app-plus/dist/uni-app-service.es.js
packages/uni-app-plus/dist/uni-app-service.es.js
+2
-4
packages/uni-app-plus/dist/uni-app-view.umd.js
packages/uni-app-plus/dist/uni-app-view.umd.js
+1
-1
packages/uni-h5-vue/dist/vue.runtime.cjs.js
packages/uni-h5-vue/dist/vue.runtime.cjs.js
+8
-1
packages/uni-h5-vue/dist/vue.runtime.esm.js
packages/uni-h5-vue/dist/vue.runtime.esm.js
+9
-2
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+7
-7
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+7
-7
packages/uni-h5/src/framework/setup/index.ts
packages/uni-h5/src/framework/setup/index.ts
+5
-3
packages/uni-shared/dist/uni-shared.cjs.js
packages/uni-shared/dist/uni-shared.cjs.js
+5
-0
packages/uni-shared/dist/uni-shared.d.ts
packages/uni-shared/dist/uni-shared.d.ts
+2
-0
packages/uni-shared/dist/uni-shared.es.js
packages/uni-shared/dist/uni-shared.es.js
+5
-1
packages/uni-shared/src/lifecycle.ts
packages/uni-shared/src/lifecycle.ts
+6
-0
packages/uni-vue/src/componentOptions/hooks.ts
packages/uni-vue/src/componentOptions/hooks.ts
+2
-5
未找到文件。
packages/uni-app-plus/dist/uni-app-service.es.js
浏览文件 @
e135ea3d
...
...
@@ -17305,17 +17305,15 @@ var serviceContext = (function (vue) {
});
if (mpType === 'page') {
instance.__isVisible = true;
// 直接触发页面 onLoad、onShow 组件内的 onLoad 和 onShow 在注册时,直接触发一次
try {
invokeHook(publicThis, ON_LOAD, instance.attrs.__pageQuery);
delete instance.attrs.__pageQuery;
invokeHook(publicThis, ON_SHOW);
}
catch (e) {
console.error(e.message + LINEFEED + e.stack);
}
vue.nextTick(() => {
// 延迟onShow,保证组件的onShow也可以监听到
invokeHook(publicThis, ON_SHOW);
});
}
}
...
...
packages/uni-app-plus/dist/uni-app-view.umd.js
浏览文件 @
e135ea3d
此差异已折叠。
点击以展开。
packages/uni-h5-vue/dist/vue.runtime.cjs.js
浏览文件 @
e135ea3d
...
...
@@ -3844,7 +3844,14 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
if
(
target
.
type
.
__reserved
)
{
return
;
}
target
=
target
.
root
;
if
(
target
!==
target
.
root
)
{
target
=
target
.
root
;
if
(
uniShared
.
isRootImmediateHook
(
type
))
{
// 作用域应该是组件还是页面?目前绑定的是页面
const
proxy
=
target
.
proxy
;
callWithAsyncErrorHandling
(
hook
.
bind
(
proxy
),
target
,
type
,
uniShared
.
ON_LOAD
===
type
?
[
proxy
.
$page
.
options
]
:
[]);
}
}
}
const
hooks
=
target
[
type
]
||
(
target
[
type
]
=
[]);
// cache the error handling wrapper for injected hooks so the same hook
...
...
packages/uni-h5-vue/dist/vue.runtime.esm.js
浏览文件 @
e135ea3d
import
{
extend
,
isArray
,
isMap
,
isIntegerKey
,
isSymbol
,
hasOwn
,
isObject
,
hasChanged
,
makeMap
,
capitalize
,
toRawType
,
def
,
isFunction
,
NOOP
,
isString
,
isPromise
,
getGlobalThis
,
EMPTY_OBJ
,
toHandlerKey
,
toNumber
,
hyphenate
,
camelize
,
isOn
,
isModelListener
,
remove
,
isSet
,
isPlainObject
,
invokeArrayFns
,
isReservedProp
,
EMPTY_ARR
,
isBuiltInDirective
,
NO
,
normalizeClass
,
normalizeStyle
,
isGloballyWhitelisted
,
isSpecialBooleanAttr
,
includeBooleanAttr
,
looseIndexOf
,
looseEqual
,
isHTMLTag
,
isSVGTag
}
from
'
@vue/shared
'
;
export
{
camelize
,
capitalize
,
normalizeClass
,
normalizeProps
,
normalizeStyle
,
toDisplayString
,
toHandlerKey
}
from
'
@vue/shared
'
;
import
{
isRootHook
}
from
'
@dcloudio/uni-shared
'
;
import
{
isRootHook
,
isRootImmediateHook
,
ON_LOAD
}
from
'
@dcloudio/uni-shared
'
;
function
warn
(
msg
,
...
args
)
{
console
.
warn
(
`[Vue warn]
${
msg
}
`
,
...
args
);
...
...
@@ -3869,7 +3869,14 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
if
(
target
.
type
.
__reserved
)
{
return
;
}
target
=
target
.
root
;
if
(
target
!==
target
.
root
)
{
target
=
target
.
root
;
if
(
isRootImmediateHook
(
type
))
{
// 作用域应该是组件还是页面?目前绑定的是页面
const
proxy
=
target
.
proxy
;
callWithAsyncErrorHandling
(
hook
.
bind
(
proxy
),
target
,
type
,
ON_LOAD
===
type
?
[
proxy
.
$page
.
options
]
:
[]);
}
}
}
const
hooks
=
target
[
type
]
||
(
target
[
type
]
=
[]);
// cache the error handling wrapper for injected hooks so the same hook
...
...
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
e135ea3d
...
...
@@ -4306,7 +4306,7 @@ var index$t = /* @__PURE__ */ defineBuiltInComponent({
slots
})
{
const
vm
=
vue
.
getCurrentInstance
();
const
__scopeId
=
vm
&&
vm
.
root
.
type
.
__
scopeId
||
""
;
const
__scopeId
=
vm
&&
vm
.
vnode
.
scopeId
||
""
;
const
{
hovering
,
binding
...
...
@@ -5151,7 +5151,7 @@ var index$p = /* @__PURE__ */ defineBuiltInComponent({
if
(
typeof
nodes
===
"
string
"
)
{
nodes
=
parseHtml
(
nodes
);
}
const
nodeList
=
parseNodes
(
nodes
,
document
.
createDocumentFragment
(),
(
vm
&&
vm
.
root
.
type
).
__
scopeId
||
""
,
hasItemClick
&&
triggerItemClick
);
const
nodeList
=
parseNodes
(
nodes
,
document
.
createDocumentFragment
(),
vm
&&
vm
.
vnode
.
scopeId
||
""
,
hasItemClick
&&
triggerItemClick
);
rootRef
.
value
.
firstElementChild
.
innerHTML
=
""
;
rootRef
.
value
.
firstElementChild
.
appendChild
(
nodeList
);
}
...
...
@@ -6579,12 +6579,10 @@ function initHooks(options, instance, publicThis) {
try
{
invokeHook
(
publicThis
,
uniShared
.
ON_LOAD
,
instance
.
attrs
.
__pageQuery
);
delete
instance
.
attrs
.
__pageQuery
;
invokeHook
(
publicThis
,
uniShared
.
ON_SHOW
);
}
catch
(
e2
)
{
console
.
error
(
e2
.
message
+
uniShared
.
LINEFEED
+
e2
.
stack
);
}
vue
.
nextTick
(()
=>
{
invokeHook
(
publicThis
,
uniShared
.
ON_SHOW
);
});
}
}
function
applyOptions
(
options
,
instance
,
publicThis
)
{
...
...
@@ -6977,9 +6975,11 @@ function setupPage(comp) {
setup
(
instance
)
{
instance
.
root
=
instance
;
const
route
=
usePageRoute
();
instance
.
attrs
.
__pageQuery
=
uniShared
.
decodedQuery
(
route
.
query
);
const
query
=
uniShared
.
decodedQuery
(
route
.
query
);
instance
.
attrs
.
__pageQuery
=
query
;
instance
.
proxy
.
$page
.
options
=
query
;
{
return
instance
.
attrs
.
__pageQ
uery
;
return
q
uery
;
}
}
});
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
e135ea3d
...
...
@@ -10177,7 +10177,7 @@ var index$q = /* @__PURE__ */ defineBuiltInComponent({
slots
}) {
const vm = getCurrentInstance();
const __scopeId = vm && vm.
root.type.__
scopeId || "";
const __scopeId = vm && vm.
vnode.
scopeId || "";
const {
hovering,
binding
...
...
@@ -11812,7 +11812,7 @@ var index$m = /* @__PURE__ */ defineBuiltInComponent({
if (typeof nodes === "string") {
nodes = parseHtml(nodes);
}
const nodeList = parseNodes(nodes, document.createDocumentFragment(),
(vm && vm.root.type).__
scopeId || "", hasItemClick && triggerItemClick);
const nodeList = parseNodes(nodes, document.createDocumentFragment(),
vm && vm.vnode.
scopeId || "", hasItemClick && triggerItemClick);
rootRef.value.firstElementChild.innerHTML = "";
rootRef.value.firstElementChild.appendChild(nodeList);
}
...
...
@@ -13605,12 +13605,10 @@ function initHooks(options, instance2, publicThis) {
try {
invokeHook(publicThis, ON_LOAD, instance2.attrs.__pageQuery);
delete instance2.attrs.__pageQuery;
invokeHook(publicThis, ON_SHOW);
} catch (e2) {
console.error(e2.message + LINEFEED + e2.stack);
}
nextTick(() => {
invokeHook(publicThis, ON_SHOW);
});
}
}
function applyOptions(options, instance2, publicThis) {
...
...
@@ -14174,7 +14172,9 @@ function setupPage(comp) {
setup(instance2) {
instance2.root = instance2;
const route = usePageRoute();
instance2.attrs.__pageQuery = decodedQuery(route.query);
const query = decodedQuery(route.query);
instance2.attrs.__pageQuery = query;
instance2.proxy.$page.options = query;
const pageMeta = usePageMeta();
onBeforeMount(() => {
onPageShow(instance2, pageMeta);
...
...
@@ -14203,7 +14203,7 @@ function setupPage(comp) {
onBeforeUnmount(() => {
unsubscribeViewMethod(pageMeta.id);
});
return
route.
query;
return query;
}
});
}
...
...
packages/uni-h5/src/framework/setup/index.ts
浏览文件 @
e135ea3d
...
...
@@ -88,9 +88,11 @@ export function setupPage(comp: any) {
instance
.
root
=
instance
// 组件 root 指向页面
const
route
=
usePageRoute
()
// 存储参数,让 initHooks 中执行 onLoad 时,可以访问到
instance
.
attrs
.
__pageQuery
=
decodedQuery
(
route
.
query
)
const
query
=
decodedQuery
(
route
.
query
)
instance
.
attrs
.
__pageQuery
=
query
instance
.
proxy
!
.
$page
.
options
=
query
if
(
__NODE_JS__
)
{
return
instance
.
attrs
.
__pageQuery
as
Record
<
string
,
unknown
>
return
query
}
const
pageMeta
=
usePageMeta
()
onBeforeMount
(()
=>
{
...
...
@@ -122,7 +124,7 @@ export function setupPage(comp: any) {
unsubscribeViewMethod
(
pageMeta
.
id
!
)
})
return
route
.
query
return
query
},
})
}
...
...
packages/uni-shared/dist/uni-shared.cjs.js
浏览文件 @
e135ea3d
...
...
@@ -1273,6 +1273,10 @@ const PAGE_HOOKS = [
ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED
,
ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED
,
];
const
PAGE_SYNC_HOOKS
=
[
ON_LOAD
,
ON_SHOW
];
function
isRootImmediateHook
(
name
)
{
return
PAGE_SYNC_HOOKS
.
indexOf
(
name
)
>
-
1
;
}
function
isRootHook
(
name
)
{
return
PAGE_HOOKS
.
indexOf
(
name
)
>
-
1
;
}
...
...
@@ -1520,6 +1524,7 @@ exports.isH5CustomElement = isH5CustomElement;
exports
.
isH5NativeTag
=
isH5NativeTag
;
exports
.
isMiniProgramNativeTag
=
isMiniProgramNativeTag
;
exports
.
isRootHook
=
isRootHook
;
exports
.
isRootImmediateHook
=
isRootImmediateHook
;
exports
.
normalizeDataset
=
normalizeDataset
;
exports
.
normalizeEventType
=
normalizeEventType
;
exports
.
normalizeTarget
=
normalizeTarget
;
...
...
packages/uni-shared/dist/uni-shared.d.ts
浏览文件 @
e135ea3d
...
...
@@ -272,6 +272,8 @@ export declare function isMiniProgramNativeTag(tag: string): boolean;
export
declare
function
isRootHook
(
name
:
string
):
boolean
;
export
declare
function
isRootImmediateHook
(
name
:
string
):
boolean
;
export
declare
interface
IUniPageNode
{
pageId
:
number
;
pageNode
:
IUniPageNode
|
null
;
...
...
packages/uni-shared/dist/uni-shared.es.js
浏览文件 @
e135ea3d
...
...
@@ -1269,6 +1269,10 @@ const PAGE_HOOKS = [
ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED
,
ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED
,
];
const
PAGE_SYNC_HOOKS
=
[
ON_LOAD
,
ON_SHOW
];
function
isRootImmediateHook
(
name
)
{
return
PAGE_SYNC_HOOKS
.
indexOf
(
name
)
>
-
1
;
}
function
isRootHook
(
name
)
{
return
PAGE_HOOKS
.
indexOf
(
name
)
>
-
1
;
}
...
...
@@ -1380,4 +1384,4 @@ function getEnvLocale() {
return
(
lang
&&
lang
.
replace
(
/
[
.:
]
.*/
,
''
))
||
'
en
'
;
}
export
{
ACTION_TYPE_ADD_EVENT
,
ACTION_TYPE_ADD_WXS_EVENT
,
ACTION_TYPE_CREATE
,
ACTION_TYPE_EVENT
,
ACTION_TYPE_INSERT
,
ACTION_TYPE_PAGE_CREATE
,
ACTION_TYPE_PAGE_CREATED
,
ACTION_TYPE_PAGE_SCROLL
,
ACTION_TYPE_REMOVE
,
ACTION_TYPE_REMOVE_ATTRIBUTE
,
ACTION_TYPE_REMOVE_EVENT
,
ACTION_TYPE_SET_ATTRIBUTE
,
ACTION_TYPE_SET_TEXT
,
ATTR_CHANGE_PREFIX
,
ATTR_CLASS
,
ATTR_INNER_HTML
,
ATTR_STYLE
,
ATTR_TEXT_CONTENT
,
ATTR_V_OWNER_ID
,
ATTR_V_RENDERJS
,
ATTR_V_SHOW
,
BACKGROUND_COLOR
,
BUILT_IN_TAGS
,
BUILT_IN_TAG_NAMES
,
COMPONENT_NAME_PREFIX
,
COMPONENT_PREFIX
,
COMPONENT_SELECTOR_PREFIX
,
DATA_RE
,
E$1
as
Emitter
,
EventChannel
,
EventModifierFlags
,
I18N_JSON_DELIMITERS
,
JSON_PROTOCOL
,
LINEFEED
,
MINI_PROGRAM_PAGE_RUNTIME_HOOKS
,
NAVBAR_HEIGHT
,
NODE_TYPE_COMMENT
,
NODE_TYPE_ELEMENT
,
NODE_TYPE_PAGE
,
NODE_TYPE_TEXT
,
NVUE_BUILT_IN_TAGS
,
NVUE_U_BUILT_IN_TAGS
,
ON_ADD_TO_FAVORITES
,
ON_APP_ENTER_BACKGROUND
,
ON_APP_ENTER_FOREGROUND
,
ON_BACK_PRESS
,
ON_ERROR
,
ON_HIDE
,
ON_KEYBOARD_HEIGHT_CHANGE
,
ON_LAUNCH
,
ON_LOAD
,
ON_NAVIGATION_BAR_BUTTON_TAP
,
ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED
,
ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED
,
ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED
,
ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED
,
ON_PAGE_NOT_FOUND
,
ON_PAGE_SCROLL
,
ON_PULL_DOWN_REFRESH
,
ON_REACH_BOTTOM
,
ON_REACH_BOTTOM_DISTANCE
,
ON_READY
,
ON_RESIZE
,
ON_SHARE_APP_MESSAGE
,
ON_SHARE_TIMELINE
,
ON_SHOW
,
ON_TAB_ITEM_TAP
,
ON_THEME_CHANGE
,
ON_UNHANDLE_REJECTION
,
ON_UNLOAD
,
ON_WEB_INVOKE_APP_SERVICE
,
ON_WXS_INVOKE_CALL_METHOD
,
PLUS_RE
,
PRIMARY_COLOR
,
RENDERJS_MODULES
,
RESPONSIVE_MIN_WIDTH
,
SCHEME_RE
,
SELECTED_COLOR
,
SLOT_DEFAULT_NAME
,
TABBAR_HEIGHT
,
TAGS
,
UNI_SSR
,
UNI_SSR_DATA
,
UNI_SSR_GLOBAL_DATA
,
UNI_SSR_STORE
,
UNI_SSR_TITLE
,
UNI_STORAGE_LOCALE
,
UniBaseNode
,
UniCommentNode
,
UniElement
,
UniEvent
,
UniInputElement
,
UniLifecycleHooks
,
UniNode
,
UniTextAreaElement
,
UniTextNode
,
WEB_INVOKE_APPSERVICE
,
WXS_MODULES
,
WXS_PROTOCOL
,
addFont
,
addLeadingSlash
,
cache
,
cacheStringFunction
,
callOptions
,
createIsCustomElement
,
createRpx2Unit
,
createUniEvent
,
customizeEvent
,
debounce
,
decode
,
decodedQuery
,
defaultMiniProgramRpx2Unit
,
defaultNVueRpx2Unit
,
defaultRpx2Unit
,
dynamicSlotName
,
forcePatchProp
,
formatAppLog
,
formatDateTime
,
formatH5Log
,
formatLog
,
getCustomDataset
,
getEnvLocale
,
getLen
,
getValueByDataPath
,
initCustomDatasetOnce
,
invokeArrayFns
,
invokeCreateVueAppHook
,
isAppNVueNativeTag
,
isAppNativeTag
,
isBuiltInComponent
,
isComponentInternalInstance
,
isComponentTag
,
isH5CustomElement
,
isH5NativeTag
,
isMiniProgramNativeTag
,
isRootHook
,
normalizeDataset
,
normalizeEventType
,
normalizeTarget
,
onCreateVueApp
,
once
,
parseEventName
,
parseNVueDataset
,
parseQuery
,
parseUrl
,
passive
,
plusReady
,
removeLeadingSlash
,
resolveComponentInstance
,
resolveOwnerEl
,
resolveOwnerVm
,
sanitise
,
scrollTo
,
stringifyQuery
,
updateElementStyle
};
export
{
ACTION_TYPE_ADD_EVENT
,
ACTION_TYPE_ADD_WXS_EVENT
,
ACTION_TYPE_CREATE
,
ACTION_TYPE_EVENT
,
ACTION_TYPE_INSERT
,
ACTION_TYPE_PAGE_CREATE
,
ACTION_TYPE_PAGE_CREATED
,
ACTION_TYPE_PAGE_SCROLL
,
ACTION_TYPE_REMOVE
,
ACTION_TYPE_REMOVE_ATTRIBUTE
,
ACTION_TYPE_REMOVE_EVENT
,
ACTION_TYPE_SET_ATTRIBUTE
,
ACTION_TYPE_SET_TEXT
,
ATTR_CHANGE_PREFIX
,
ATTR_CLASS
,
ATTR_INNER_HTML
,
ATTR_STYLE
,
ATTR_TEXT_CONTENT
,
ATTR_V_OWNER_ID
,
ATTR_V_RENDERJS
,
ATTR_V_SHOW
,
BACKGROUND_COLOR
,
BUILT_IN_TAGS
,
BUILT_IN_TAG_NAMES
,
COMPONENT_NAME_PREFIX
,
COMPONENT_PREFIX
,
COMPONENT_SELECTOR_PREFIX
,
DATA_RE
,
E$1
as
Emitter
,
EventChannel
,
EventModifierFlags
,
I18N_JSON_DELIMITERS
,
JSON_PROTOCOL
,
LINEFEED
,
MINI_PROGRAM_PAGE_RUNTIME_HOOKS
,
NAVBAR_HEIGHT
,
NODE_TYPE_COMMENT
,
NODE_TYPE_ELEMENT
,
NODE_TYPE_PAGE
,
NODE_TYPE_TEXT
,
NVUE_BUILT_IN_TAGS
,
NVUE_U_BUILT_IN_TAGS
,
ON_ADD_TO_FAVORITES
,
ON_APP_ENTER_BACKGROUND
,
ON_APP_ENTER_FOREGROUND
,
ON_BACK_PRESS
,
ON_ERROR
,
ON_HIDE
,
ON_KEYBOARD_HEIGHT_CHANGE
,
ON_LAUNCH
,
ON_LOAD
,
ON_NAVIGATION_BAR_BUTTON_TAP
,
ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED
,
ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED
,
ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED
,
ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED
,
ON_PAGE_NOT_FOUND
,
ON_PAGE_SCROLL
,
ON_PULL_DOWN_REFRESH
,
ON_REACH_BOTTOM
,
ON_REACH_BOTTOM_DISTANCE
,
ON_READY
,
ON_RESIZE
,
ON_SHARE_APP_MESSAGE
,
ON_SHARE_TIMELINE
,
ON_SHOW
,
ON_TAB_ITEM_TAP
,
ON_THEME_CHANGE
,
ON_UNHANDLE_REJECTION
,
ON_UNLOAD
,
ON_WEB_INVOKE_APP_SERVICE
,
ON_WXS_INVOKE_CALL_METHOD
,
PLUS_RE
,
PRIMARY_COLOR
,
RENDERJS_MODULES
,
RESPONSIVE_MIN_WIDTH
,
SCHEME_RE
,
SELECTED_COLOR
,
SLOT_DEFAULT_NAME
,
TABBAR_HEIGHT
,
TAGS
,
UNI_SSR
,
UNI_SSR_DATA
,
UNI_SSR_GLOBAL_DATA
,
UNI_SSR_STORE
,
UNI_SSR_TITLE
,
UNI_STORAGE_LOCALE
,
UniBaseNode
,
UniCommentNode
,
UniElement
,
UniEvent
,
UniInputElement
,
UniLifecycleHooks
,
UniNode
,
UniTextAreaElement
,
UniTextNode
,
WEB_INVOKE_APPSERVICE
,
WXS_MODULES
,
WXS_PROTOCOL
,
addFont
,
addLeadingSlash
,
cache
,
cacheStringFunction
,
callOptions
,
createIsCustomElement
,
createRpx2Unit
,
createUniEvent
,
customizeEvent
,
debounce
,
decode
,
decodedQuery
,
defaultMiniProgramRpx2Unit
,
defaultNVueRpx2Unit
,
defaultRpx2Unit
,
dynamicSlotName
,
forcePatchProp
,
formatAppLog
,
formatDateTime
,
formatH5Log
,
formatLog
,
getCustomDataset
,
getEnvLocale
,
getLen
,
getValueByDataPath
,
initCustomDatasetOnce
,
invokeArrayFns
,
invokeCreateVueAppHook
,
isAppNVueNativeTag
,
isAppNativeTag
,
isBuiltInComponent
,
isComponentInternalInstance
,
isComponentTag
,
isH5CustomElement
,
isH5NativeTag
,
isMiniProgramNativeTag
,
isRootHook
,
isRootImmediateHook
,
normalizeDataset
,
normalizeEventType
,
normalizeTarget
,
onCreateVueApp
,
once
,
parseEventName
,
parseNVueDataset
,
parseQuery
,
parseUrl
,
passive
,
plusReady
,
removeLeadingSlash
,
resolveComponentInstance
,
resolveOwnerEl
,
resolveOwnerVm
,
sanitise
,
scrollTo
,
stringifyQuery
,
updateElementStyle
};
packages/uni-shared/src/lifecycle.ts
浏览文件 @
e135ea3d
...
...
@@ -45,6 +45,12 @@ const PAGE_HOOKS = [
ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED
,
]
const
PAGE_SYNC_HOOKS
=
[
ON_LOAD
,
ON_SHOW
]
export
function
isRootImmediateHook
(
name
:
string
)
{
return
PAGE_SYNC_HOOKS
.
indexOf
(
name
)
>
-
1
}
export
function
isRootHook
(
name
:
string
)
{
return
PAGE_HOOKS
.
indexOf
(
name
)
>
-
1
}
...
...
packages/uni-vue/src/componentOptions/hooks.ts
浏览文件 @
e135ea3d
...
...
@@ -3,7 +3,6 @@ import { LINEFEED, ON_LOAD, ON_SHOW } from '@dcloudio/uni-shared'
import
{
isArray
,
isFunction
}
from
'
@vue/shared
'
import
{
nextTick
,
ComponentOptions
,
ComponentInternalInstance
,
ComponentPublicInstance
,
...
...
@@ -46,15 +45,13 @@ export function initHooks(
})
if
((
__PLATFORM__
===
'
app
'
||
__PLATFORM__
===
'
h5
'
)
&&
mpType
===
'
page
'
)
{
instance
.
__isVisible
=
true
// 直接触发页面 onLoad、onShow 组件内的 onLoad 和 onShow 在注册时,直接触发一次
try
{
invokeHook
(
publicThis
,
ON_LOAD
,
instance
.
attrs
.
__pageQuery
)
delete
instance
.
attrs
.
__pageQuery
invokeHook
(
publicThis
,
ON_SHOW
)
}
catch
(
e
:
any
)
{
console
.
error
(
e
.
message
+
LINEFEED
+
e
.
stack
)
}
nextTick
(()
=>
{
// 延迟onShow,保证组件的onShow也可以监听到
invokeHook
(
publicThis
,
ON_SHOW
)
})
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录