提交 79938ccf 编写于 作者: Q qiang

fix(App): keep onReady before mounted when use composition-api

上级 92fc4231
export declare function init(): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.init = void 0;
var Vue = require("vue");
function init() {
var vueConstructor = (Vue.default ? Vue.default : Vue);
var defaultMergeHook = vueConstructor.config.optionMergeStrategies.mounted;
var onReadyFn;
vueConstructor.config.optionMergeStrategies.mounted = function Le(parentVal, childVal) {
var res = defaultMergeHook.call(this, parentVal, childVal);
if (Array.isArray(res)) {
var index = void 0;
if (onReadyFn) {
index = res.indexOf(onReadyFn);
}
else {
index = res.findIndex(function (fn) { return fn.toString().includes('onReady'); });
onReadyFn = res[index];
}
res.splice(index, 1);
res.push(onReadyFn);
}
console.log('Merge mounted:', res);
return res;
};
}
exports.init = init;
......@@ -2,6 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.onNavigationBarSearchInputClicked = exports.onNavigationBarSearchInputConfirmed = exports.onNavigationBarSearchInputChanged = exports.onBackPress = exports.onNavigationBarButtonTap = exports.onTabItemTap = exports.onResize = exports.onPageScroll = exports.onAddToFavorites = exports.onShareTimeline = exports.onShareAppMessage = exports.onReachBottom = exports.onPullDownRefresh = exports.onUnload = exports.onReady = exports.onLoad = exports.onInit = exports.onUniNViewMessage = exports.onThemeChange = exports.onUnhandledRejection = exports.onPageNotFound = exports.onError = exports.onLaunch = exports.onHide = exports.onShow = exports.initUtsPackageName = exports.initUtsClassName = exports.initUtsIndexClassName = exports.initUtsProxyFunction = exports.initUtsProxyClass = void 0;
var composition_api_1 = require("@vue/composition-api");
var app = require("./app");
var mp = require("./mp");
var uts_1 = require("./uts");
Object.defineProperty(exports, "initUtsProxyClass", { enumerable: true, get: function () { return uts_1.initUtsProxyClass; } });
......@@ -18,6 +19,7 @@ var createLifeCycle = function (lifecycle) {
};
};
if (typeof plus === 'object') {
app.init();
}
else if (typeof window === 'object' && 'document' in window) {
}
......
import Vue = require('vue')
type MergeHook = (parentVal: undefined | Function[], childVal?: Function | Function[]) => void | Function[]
export function init() {
const vueConstructor = (Vue.default ? Vue.default : Vue) as typeof Vue.default
const defaultMergeHook = vueConstructor.config.optionMergeStrategies.mounted as MergeHook
let onReadyFn: Function
// 向后移动 onReady 触发时机,暂不改动主框架
vueConstructor.config.optionMergeStrategies.mounted = function Le(parentVal: undefined | Function[], childVal?: Function | Function[]) {
const res = defaultMergeHook.call(this, parentVal, childVal) as ReturnType<MergeHook>
if (Array.isArray(res)) {
let index: number
if (onReadyFn) {
index = res.indexOf(onReadyFn)
} else {
index = res.findIndex(fn => fn.toString().includes('onReady'))
onReadyFn = res[index]
}
if (index !== -1) {
res.splice(index, 1)
res.push(onReadyFn)
}
}
return res
}
}
/// <reference types="@dcloudio/types" />
import { createLifeCycle as createLifeCycleBase, ComponentInternalInstance } from '@vue/composition-api'
import * as app from './app'
import * as mp from './mp'
export {
initUtsProxyClass,
initUtsProxyFunction,
initUtsIndexClassName,
initUtsClassName,
initUtsPackageName,
} from './uts'
} from './uts'
const lifecycles: string[] = []
......@@ -20,7 +21,7 @@ const createLifeCycle = <T extends Function>(lifecycle: string) => {
}
}
if (typeof plus === 'object') {
// TODO App
app.init()
} else if (typeof window === 'object' && 'document' in window) {
// TODO H5
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册