平台支持

说明: 下面对比表格,生命周期对比表格里,括号里注明的为对应的原生生命周期调用方法

App 生命周期

生命周期 微信 百度 支付宝 头条 快应用
onLaunch √(onCreate
onShow x
onHide x
onError √(1030+支持)

Page 生命周期

生命周期 微信 百度 支付宝 头条 快应用
beforeCreate √(onLoad √(onLoad √(onLoad √(onLoad √(onInit
created √(onLoad √(onLoad √(onLoad √(onLoad √(onInit
beforeMount √(onReady √(onReady √(onReady √(onReady √(onReady
mounted √(onReady √(onReady √(onReady √(onReady √(onReady
beforeDestroy √(onUnload √(onUnload √(onUnload √(onUnload √(onDestroy
destroyed √(onUnload √(onUnload √(onUnload √(onUnload √(onDestroy
onShow
onHide

自定义组件生命周期

生命周期 微信 百度 支付宝 头条 快应用
beforeCreate √(created √(created √(didMount √(created √(onInit
created √(didMount √(onInit
beforeMount √(attached √(attached √(didMount √(attached √(onReady
mounted √(ready √(ready √(didMount √(ready √(onReady
beforeDestroy √(detached √(detached √(didUnmount √(detached √(onDestroy
destroyed √(detached √(detached √(didUnmount √(detached √(onDestroy

页面路由导航

路由导航,统一使用如下 API:

  • $api.navigateBack
  • $api.navigateTo
  • $api.redirectTo

为了保证各个平台导航一致性,建议全部用绝对路径,即导航 url 以 / 开头,一方面路径更清晰,其次可以更好兼容 快应用

框架能力支持

功能 微信 百度 支付宝 头条 快应用 备注
computed -
watch -
mixin -
模板复用 √(内联实现 -
filter x -
v-model x -
ref -
broadcast -
redux状态管理 -
原生组件支持 不能跨平台

参考