diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js index 3a7236d7b84c7d2d9e349428d0ebdfa56927378a..c1836bc36c30f834f2ca299334353771409b5fb0 100644 --- a/packages/uni-mp-weixin/dist/index.js +++ b/packages/uni-mp-weixin/dist/index.js @@ -562,30 +562,6 @@ const hooks$1 = [ 'onNavigationBarSearchInputClicked' ]; -function attached (VueComponent) { - - this.$vm = new VueComponent({ - mpType: 'page', - mpInstance: this - }); - - this.$vm.__call_hook('created'); - this.$vm.$mount(); -} - -function ready () { - this.$vm.__call_hook('beforeMount'); - this.$vm._isMounted = true; - this.$vm.__call_hook('mounted'); - this.$vm.__call_hook('onReady'); -} - -function detached () { - this.$vm.__call_hook('onUnload'); - { - this.$vm.$destroy(); - } -} function createPage (vueOptions) { vueOptions = vueOptions.default || vueOptions; let VueComponent; @@ -603,19 +579,32 @@ function createPage (vueOptions) { data: getData(vueOptions, Vue.prototype), lifetimes: { // 当页面作为组件时 attached () { - attached.call(this, VueComponent); + + this.$vm = new VueComponent({ + mpType: 'page', + mpInstance: this + }); + + this.$vm.__call_hook('created'); + this.$vm.$mount(); }, ready () { - ready.call(this); + this.$vm.__call_hook('beforeMount'); + this.$vm._isMounted = true; + this.$vm.__call_hook('mounted'); + this.$vm.__call_hook('onReady'); }, detached () { - detached.call(this); + this.$vm.$destroy(); } }, methods: { // 作为页面时 onLoad (args) { - this.$vm.$mp.query = args; // 又要兼容 mpvue - this.$vm.__call_hook('onLoad', args); // 开发者可能会在 onLoad 时赋值,提前到 mount 之前 + this.$vm.$mp.query = args; // 又要兼容 mpvue + this.$vm.__call_hook('onLoad', args); // 开发者可能会在 onLoad 时赋值,提前到 mount 之前 + }, + onUnload () { + this.$vm.__call_hook('onUnload'); }, __e: handleEvent, __l: handleLink diff --git a/packages/uni-mp-weixin/package.json b/packages/uni-mp-weixin/package.json index 96a99c15da0b2797aed1f635f31da4148131d11e..6cb77b63f6469b359771944cc68583827b14348a 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.921", + "version": "0.0.922", "description": "uni-app mp-weixin", "main": "dist/index.js", "scripts": { diff --git a/src/core/runtime/wrapper/create-page.js b/src/core/runtime/wrapper/create-page.js index a4f68d3522dfc0c07dbdee58b104e8c7dc8236be..0057add4a8efb197efa50db2de16eef89229379c 100644 --- a/src/core/runtime/wrapper/create-page.js +++ b/src/core/runtime/wrapper/create-page.js @@ -31,35 +31,6 @@ const hooks = [ 'onNavigationBarSearchInputClicked' ] -function attached (VueComponent) { - if (__PLATFORM__ === 'mp-baidu') { - this.$baiduComponentInstances = Object.create(null) - } - - this.$vm = new VueComponent({ - mpType: 'page', - mpInstance: this - }) - - this.$vm.__call_hook('created') - this.$vm.$mount() -} - -function ready () { - this.$vm.__call_hook('beforeMount') - this.$vm._isMounted = true - this.$vm.__call_hook('mounted') - this.$vm.__call_hook('onReady') -} - -function detached () { - this.$vm.__call_hook('onUnload') - if (__PLATFORM__ === 'mp-baidu') { // 百度组件不会在页面 unload 时触发 detached - baiduPageDestroy(this.$vm) - } else { - this.$vm.$destroy() - } -} export function createPage (vueOptions) { vueOptions = vueOptions.default || vueOptions let VueComponent @@ -77,19 +48,38 @@ export function createPage (vueOptions) { data: getData(vueOptions, Vue.prototype), lifetimes: { // 当页面作为组件时 attached () { - attached.call(this, VueComponent) + if (__PLATFORM__ === 'mp-baidu') { + this.$baiduComponentInstances = Object.create(null) + } + + this.$vm = new VueComponent({ + mpType: 'page', + mpInstance: this + }) + + this.$vm.__call_hook('created') + this.$vm.$mount() }, ready () { - ready.call(this) + this.$vm.__call_hook('beforeMount') + this.$vm._isMounted = true + this.$vm.__call_hook('mounted') + this.$vm.__call_hook('onReady') }, detached () { - detached.call(this) + this.$vm.$destroy() } }, methods: { // 作为页面时 onLoad (args) { - this.$vm.$mp.query = args // 又要兼容 mpvue - this.$vm.__call_hook('onLoad', args) // 开发者可能会在 onLoad 时赋值,提前到 mount 之前 + this.$vm.$mp.query = args // 又要兼容 mpvue + this.$vm.__call_hook('onLoad', args) // 开发者可能会在 onLoad 时赋值,提前到 mount 之前 + }, + onUnload () { + this.$vm.__call_hook('onUnload') + if (__PLATFORM__ === 'mp-baidu') { // 百度组件不会在页面 unload 时触发 detached + baiduPageDestroy(this.$vm) + } }, __e: handleEvent, __l: handleLink