-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(runtime): 修复、迭代生命周期 #6996
fix(runtime): 修复、迭代生命周期 #6996
Conversation
* 生命周期 hooks 在组件销毁时,同时销毁监听回调。 * 修复页面为 Class 组件,子组件使用生命周期 hooks 时不触发回调的问题。
* 增加 onAddToFavorites、onShareTimeline 页面事件 hooks * 【Breaking】使用 onShareAppMessage,useShareAppMessage 时,必须设置页面的 enableShareAppMessage 属性为 true,#6825
} | ||
|
||
// onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。 | ||
if (component.onShareAppMessage || component.enableShareAppMessage) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Chen-jj 这里不应该是 component.prototype.onShareAppMessage
吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
component.onShareAppMessage
是给 Vue 用的,根据 prototype 判断可以加下,那么 Class Component 就不用配置 enable 了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
记录一下:这样还是不完美,HOC 如 connect 后的页面组件会跪,还是要编译时处理一下以自动兼容大部分情况。
} else { | ||
inst![lifecycle] = callback | ||
if (isFunction(inst[lifecycle])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Chen-jj 如果上面 common.ts 里修复了, 页面实例就没有默认的 onShareAppMessage 回调了, 在函数式组件里 inst[lifecycle] 永远是 undefined, 我们还是应该用 lifecycle 这个字符串上来判断, 以实现页面第一次初始化时设置 onShareAppMessage/onShareTimeline/onAddToFavorites
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createPageConfig 时 inst 是 undefined,小程序 onLoad 时才会绑定。
这个 PR 做了什么? (简要描述所做更改)
修复
特性
这个 PR 是什么类型? (至少选择一个)
这个 PR 满足以下需求:
这个 PR 涉及以下平台: