提交 989d7092 编写于 作者: fxy060608's avatar fxy060608

feat(mp-baidu): Pass page parameters to props (#3402)

上级 3ced7aa4
...@@ -42,7 +42,7 @@ export function parse(componentOptions: MPComponentOptions) { ...@@ -42,7 +42,7 @@ export function parse(componentOptions: MPComponentOptions) {
const pages = getCurrentPages() const pages = getCurrentPages()
this.pageinstance = pages[pages.length - 1] this.pageinstance = pages[pages.length - 1]
} }
this.pageinstance._$props = query
// 处理百度小程序 onInit 生命周期调用 setData 无效的问题 // 处理百度小程序 onInit 生命周期调用 setData 无效的问题
fixSetDataStart(this as MPComponentInstance) fixSetDataStart(this as MPComponentInstance)
oldAttached.call(this) oldAttached.call(this)
......
...@@ -46,11 +46,19 @@ export function initLifetimes({ ...@@ -46,11 +46,19 @@ export function initLifetimes({
// 初始化 vue 实例 // 初始化 vue 实例
const mpInstance = this const mpInstance = this
const isMiniProgramPage = isPage(mpInstance) const isMiniProgramPage = isPage(mpInstance)
let propsData: Record<string, any> = {}
if (__PLATFORM__ === 'mp-baidu' && isMiniProgramPage) {
// 百度小程序在 onInit 时就可以临时存储下页面参数
const { _$props } = (this as any).pageinstance
delete (this as any).pageinstance._$props
propsData = findPropsData(_$props, true)
} else {
propsData = findPropsData(properties, isMiniProgramPage)
}
this.$vm = $createComponent( this.$vm = $createComponent(
{ {
type: vueOptions, type: vueOptions,
props: findPropsData(properties, isMiniProgramPage), props: propsData,
}, },
{ {
mpType: isMiniProgramPage ? 'page' : 'component', mpType: isMiniProgramPage ? 'page' : 'component',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册