Skip to content

[FEATURE] 支持百度小程序生命周期改动 lifecycle-2-0 #165

@allen-zh

Description

@allen-zh

根据百度智能小程序发布的生命周期改动重要公告:
【公告】小程序生命周期改动(重要)
https://smartprogram.baidu.com/forum/topic/show/70128

此次生命周期非兼容性改动将会影响 Mars 框架在百度小程序中的运行,目前 Mars 框架已完成升级适配支持:
使用 0.2.x 版本的开发者需升级 @marsjs/core 版本至 @marsjs/[email protected]
使用 0.3.x-alpha 版本的开发者需升级 @marsjs/core 版本至 @marsjs/[email protected]

此次框架升级只是使框架本身适配小程序生命周期改动,对于业务逻辑中可能存在的对于小程序生命周期顺序和其他改动的依赖,开发者需自行处理,详见小程序公告。

另外,0.3.x-alpha 版本此次升级会引入一个【非兼容变化】:

0.3.x-alpha 版本升级后,组件对应的 vue 实例创建时机统一到小程序的 lifetimes.attached 生命周期,导致在 swan 的 lifetimes.created 生命周期中将无法通过 this 获取到 vue 实例,lifetimes.createdthis 中可以访问 $api$mp.scope (指向小程序组件实例)属性。
如果有在 lifetimes.created 生命周期中通过 this 获取和操作 vue 实例,需要将逻辑迁移至 swan 的 lifetimes.attached 或者 vue 的 created 生命周期。

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions