dcloudio / dcloudio/uni-app

created onLoad在h5和小程序中,执行的顺序不一致

Open
#2,572 2 comments 0 reactions 1 assignee Claimed by @Otto-J View on GitHub
mp-weixin question
Dominant language
JavaScript
Stars
41.6k
Forks
3.7k
Avg merge
7h 6m
Merged PRs (30d)
6

Description

**问题描述**
按照理解,`created` 和 `onLoad` 生命周期函数在各平台中均应该按照 created -> onLoad 的顺序执行,但实际上在 H5 平台中的执行顺序则是相反的,先回调了onLoad 再回调 created,不知道这个是 bug 还是官方故意为之,有何深意。

**复现步骤**

[或者可以直接贴源代码]
```
created: function() {
console.log('created')
},

onLoad: function() {
console.log('onLoad')
}
```

**预期结果**
不管是在微信小程序/支付宝小程序/H5等各平台中,均应该依次打印 `created` -> `onLoad`

**实际结果**
微信小程序/支付宝小程序打印结果:`created` -> `onLoad`
H5的打印结果:`onLoad` -> `created`

**系统信息:**
截止目前最新版 3.1.7.20210330 依然有该问题

**补充信息**
在社区里面找到了一篇反馈文章 [【报Bug】uni-app的created onLoad为什么在h5和微信小程序中,显示的顺序不一致](https://ask.dcloud.net.cn/question/112914),但是官方并没有进行任何回复。

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.