症状说明:
在router.push界面中,跳转到高速APP应用程序的b页。 如果Web页仅引用自定义组件XX,则无法触发Web页的演示生命周期。 如下图所示。
代码如下:
http://www.Sina.com/http://www.Sina.com /
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
导入名称=' listone ' src='./aa.UX '/import
模板
! --template只有一个根节点-
listone/listone
/template
脚本
importpromptfrom ' @ system.prompt '
导出默认值{
隐私: {
(,
onInit:function (
(,
onShow () }
console.log ('我显示了我,我显示了我');
prompt.showToast({ (
message: '我显示了,我显示了,我显示了'
() )
(,//无法触发
}
/脚本
斯泰尔斯
. demo-page{
flex-direction:column;
justify-content:center;
align-items3360中心;
}
. title{
font-size:40px;
文本对齐3360中心;
}
/style
B
http://www.Sina.com/http://www.Sina.com /
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
模板
divclass='container '
文本天气真好啊/文本
文本天气真好啊/文本
文本天气真好啊/文本
文本天气真好啊/文本
/div
/template
斯泰尔斯
. container{
flex-direction:column;
justify-content:center;
align-items3360中心;
背景色: # 00 f a9a;
}
/style
脚本
module.exports={
数据: {
(,
onInit () )。
(,
}
/脚本
页面代码:
问题分析:如果引擎框架将自定义组件确定为b页的根节点,则无法触发b页的现场演示生命周期,但打开子组件本身解决方案:通过将div组件添加到b页面的子组件之外,而不是将自定义组件作为根节点,可以触发b页面的现场演示生命周期。
http://www.Sina.com/http://www.Sina.com /
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
导入名称=' listone ' src='./aa.UX '/import
模板
! --template只有一个根节点-
div
listone/listone
/div
/template
脚本
importpromptfrom ' @ system.prompt '
导出默认值{
隐私: {
(,
onInit:function (
(,
onShow () }
console.log ('我显示了我,我显示了我');
prompt.showToast({ (
message: '我显示了,我显示了,我显示了'
() )
(,
}
/脚本
斯泰尔斯
. demo-page{
flex-direction:column;
justify-content:center;
align-items3360中心;
}
. title{
font-size:40px;
文本对齐3360中心;
}
/style
自定义组件aa.ux
:
有关详细信息,请参阅:
生命周期应用:
3359 developer.Huawei.com/consumer/cn/doc/development /快速应用程序/快速应用程序/脚本# H2-1575381011111
原文链接: https://developer.huawei.com/.
原作者: Mayism