diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js index 89f5169c1fdc135f71bab26754832ddb99fc621f..22abfae23ec1ae2c518717d4738e16742ee3f6fb 100644 --- a/packages/uni-mp-weixin/dist/index.js +++ b/packages/uni-mp-weixin/dist/index.js @@ -617,6 +617,9 @@ function initVueComponent (mpInstace, VueComponent, extraOptions = {}) { }); mpInstace.$vm.$scopedSlots = mpInstace.$vm.$slots = $slots; } + // 性能优先,mount 提前到 attached 中,保证组件首次渲染数据被合并 + // 导致与标准 Vue 的差异,data 和 computed 中不能使用$parent,provide等组件属性 + mpInstace.$vm.$mount(); } function createComponent (vueOptions) { @@ -641,9 +644,9 @@ function createComponent (vueOptions) { initVueComponent(this, VueComponent); // 目前发现部分情况小程序 attached 不触发 triggerLink(this); // 处理 parent,children - // 初始化渲染数据(需要等 parent,inject 都初始化完成,否则可以放到 attached 里边初始化渲染) + // 补充生命周期 this.$vm.__call_hook('created'); - this.$vm.$mount(); + this.$vm.__call_hook('beforeMount'); this.$vm._isMounted = true; this.$vm.__call_hook('mounted'); this.$vm.__call_hook('onReady'); diff --git a/packages/uni-mp-weixin/package.json b/packages/uni-mp-weixin/package.json index cf90ff816c88fcbc3f4f9b618a872107a2f3f7d4..b76cd9703a2229f5b1cbcdc1a5fcc2a7c60ae1f9 100644 --- a/packages/uni-mp-weixin/package.json +++ b/packages/uni-mp-weixin/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-weixin", - "version": "0.0.912", + "version": "0.0.913", "description": "uni-app mp-weixin", "main": "dist/index.js", "scripts": { diff --git a/src/core/runtime/wrapper/create-component.js b/src/core/runtime/wrapper/create-component.js index a3fd10111aa9a0754317cc8cb7c9d364b85e5f2b..8d8d76de008bccd9ed0c458f065feec40338677b 100644 --- a/src/core/runtime/wrapper/create-component.js +++ b/src/core/runtime/wrapper/create-component.js @@ -33,6 +33,9 @@ function initVueComponent (mpInstace, VueComponent, extraOptions = {}) { }) mpInstace.$vm.$scopedSlots = mpInstace.$vm.$slots = $slots } + // 性能优先,mount 提前到 attached 中,保证组件首次渲染数据被合并 + // 导致与标准 Vue 的差异,data 和 computed 中不能使用$parent,provide等组件属性 + mpInstace.$vm.$mount() } export function createComponent (vueOptions) { @@ -57,9 +60,9 @@ export function createComponent (vueOptions) { initVueComponent(this, VueComponent) // 目前发现部分情况小程序 attached 不触发 triggerLink(this) // 处理 parent,children - // 初始化渲染数据(需要等 parent,inject 都初始化完成,否则可以放到 attached 里边初始化渲染) + // 补充生命周期 this.$vm.__call_hook('created') - this.$vm.$mount() + this.$vm.__call_hook('beforeMount') this.$vm._isMounted = true this.$vm.__call_hook('mounted') this.$vm.__call_hook('onReady')