Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lzb_79
uni-app
提交
269e1b8c
U
uni-app
项目概览
lzb_79
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
269e1b8c
编写于
11月 16, 2021
作者:
Q
qiang
提交者:
折腾笔记
12月 15, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mp-jd): componentOptions lifetimes
上级
90fb0799
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
10 addition
and
149 deletion
+10
-149
src/platforms/mp-jd/runtime/wrapper/component-parser.js
src/platforms/mp-jd/runtime/wrapper/component-parser.js
+10
-149
未找到文件。
src/platforms/mp-jd/runtime/wrapper/component-parser.js
浏览文件 @
269e1b8c
import
Vue
from
'
vue
'
import
{
initData
,
initSlots
,
initVueIds
,
handleEvent
,
initBehaviors
,
initProperties
,
initVueComponent
}
from
'
uni-wrapper/util
'
import
{
handleLink
,
initBehavior
}
from
'
./util
'
export
default
function
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
}
=
{})
{
const
[
VueComponent
,
vueOptions
]
=
initVueComponent
(
Vue
,
vueComponentOptions
)
const
options
=
{
multipleSlots
:
true
,
addGlobalClass
:
true
,
...(
vueOptions
.
options
||
{})
}
const
componentOptions
=
{
options
,
data
:
initData
(
vueOptions
,
Vue
.
prototype
),
behaviors
:
initBehaviors
(
vueOptions
,
initBehavior
),
properties
:
initProperties
(
vueOptions
.
props
,
false
,
vueOptions
.
__file
),
lifetimes
:
{
attached
()
{
const
properties
=
this
.
properties
const
options
=
{
mpType
:
isPage
.
call
(
this
)
?
'
page
'
:
'
component
'
,
mpInstance
:
this
,
propsData
:
properties
}
initVueIds
(
properties
.
vueId
,
this
)
// 处理父子关系
initRelation
.
call
(
this
,
{
vuePid
:
this
.
_$vuePid
,
vueOptions
:
options
})
// 初始化 vue 实例
this
.
$vm
=
new
VueComponent
(
options
)
// 处理$slots,$scopedSlots(暂不支持动态变化$slots)
initSlots
(
this
.
$vm
,
properties
.
vueSlots
)
// 触发首次 setData
this
.
$vm
.
$mount
()
},
ready
()
{
// 当组件 props 默认值为 true,初始化时传入 false 会导致 created,ready 触发, 但 attached 不触发
// https://developers.weixin.qq.com/community/develop/doc/00066ae2844cc0f8eb883e2a557800
if
(
this
.
$vm
)
{
this
.
$vm
.
_isMounted
=
true
this
.
$vm
.
__call_hook
(
'
mounted
'
)
this
.
$vm
.
__call_hook
(
'
onReady
'
)
}
else
{
// this.is && console.warn(this.is + ' is not attached')
}
},
detached
()
{
this
.
$vm
&&
this
.
$vm
.
$destroy
()
},
},
pageLifetimes
:
{
show
(
args
)
{
this
.
$vm
&&
this
.
$vm
.
__call_hook
(
'
onPageShow
'
,
args
)
},
hide
()
{
this
.
$vm
&&
this
.
$vm
.
__call_hook
(
'
onPageHide
'
)
},
resize
(
size
)
{
this
.
$vm
&&
this
.
$vm
.
__call_hook
(
'
onPageResize
'
,
size
)
}
},
attached
()
{
const
properties
=
this
.
properties
const
options
=
{
mpType
:
isPage
.
call
(
this
)
?
'
page
'
:
'
component
'
,
mpInstance
:
this
,
propsData
:
properties
}
initVueIds
(
properties
.
vueId
,
this
)
// 处理父子关系
initRelation
.
call
(
this
,
{
vuePid
:
this
.
_$vuePid
,
vueOptions
:
options
})
// 初始化 vue 实例
this
.
$vm
=
new
VueComponent
(
options
)
// 处理$slots,$scopedSlots(暂不支持动态变化$slots)
initSlots
(
this
.
$vm
,
properties
.
vueSlots
)
// 触发首次 setData
this
.
$vm
.
$mount
()
},
ready
()
{
// 当组件 props 默认值为 true,初始化时传入 false 会导致 created,ready 触发, 但 attached 不触发
// https://developers.weixin.qq.com/community/develop/doc/00066ae2844cc0f8eb883e2a557800
if
(
this
.
$vm
)
{
this
.
$vm
.
_isMounted
=
true
this
.
$vm
.
__call_hook
(
'
mounted
'
)
this
.
$vm
.
__call_hook
(
'
onReady
'
)
}
else
{
// this.is && console.warn(this.is + ' is not attached')
}
},
detached
()
{
this
.
$vm
&&
this
.
$vm
.
$destroy
()
},
methods
:
{
__l
:
handleLink
,
__e
:
handleEvent
}
}
// externalClasses
if
(
vueOptions
.
externalClasses
)
{
componentOptions
.
externalClasses
=
vueOptions
.
externalClasses
}
if
(
Array
.
isArray
(
vueOptions
.
wxsCallMethods
))
{
vueOptions
.
wxsCallMethods
.
forEach
(
callMethod
=>
{
componentOptions
.
methods
[
callMethod
]
=
function
(
args
)
{
return
this
.
$vm
[
callMethod
](
args
)
}
})
}
if
(
isPage
)
{
return
componentOptions
}
return
[
componentOptions
,
VueComponent
]
import
parseBaseComponent
from
'
../../../mp-weixin/runtime/wrapper/component-parser
'
export
default
function
parseComponent
(
vueComponentOptions
)
{
const
componentOptions
=
parseBaseComponent
(
vueComponentOptions
)
// 京东小程序 lifetimes 存在兼容问题
const
lifetimes
=
componentOptions
.
lifetimes
Object
.
keys
(
lifetimes
).
forEach
(
key
=>
{
componentOptions
[
key
]
=
lifetimes
[
key
]
})
return
componentOptions
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录