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

fix(runtime): mp生命周期

上级 19d618d0
......@@ -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
......
{
"name": "@dcloudio/uni-mp-weixin",
"version": "0.0.921",
"version": "0.0.922",
"description": "uni-app mp-weixin",
"main": "dist/index.js",
"scripts": {
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册