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

fix(mp-baidu): App.vue onShow

上级 032f8902
...@@ -993,18 +993,18 @@ function handleEvent (event) { ...@@ -993,18 +993,18 @@ function handleEvent (event) {
}); });
} }
const hooks = [ const hooks = [
'onShow', 'onShow',
'onHide', 'onHide',
'onError', 'onError',
'onPageNotFound' 'onPageNotFound'
]; ];
function parseBaseApp (vm, { function parseBaseApp (vm, {
mocks, mocks,
initRefs initRefs
}) { }) {
Vue.prototype.mpHost = "mp-baidu"; Vue.prototype.mpHost = "mp-baidu";
Vue.mixin({ Vue.mixin({
beforeCreate () { beforeCreate () {
...@@ -1033,6 +1033,9 @@ function parseBaseApp (vm, { ...@@ -1033,6 +1033,9 @@ function parseBaseApp (vm, {
const appOptions = { const appOptions = {
onLaunch (args) { onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this.$vm = vm; this.$vm = vm;
...@@ -1130,10 +1133,18 @@ function initRelation$1 (detail) { ...@@ -1130,10 +1133,18 @@ function initRelation$1 (detail) {
} }
function parseApp (vm) { function parseApp (vm) {
return parseBaseApp(vm, { // 百度 onShow 竟然会在 onLaunch 之前
const appOptions = parseBaseApp(vm, {
mocks: mocks$1, mocks: mocks$1,
initRefs initRefs
}) });
appOptions.onShow = function onShow (args) {
if (!this.$vm) {
this.onLaunch(args);
}
this.$vm.__call_hook('onShow', args);
};
return appOptions
} }
function createApp (vm) { function createApp (vm) {
......
...@@ -9,8 +9,16 @@ import { ...@@ -9,8 +9,16 @@ import {
} from './util' } from './util'
export default function parseApp (vm) { export default function parseApp (vm) {
return parseBaseApp(vm, { // 百度 onShow 竟然会在 onLaunch 之前
const appOptions = parseBaseApp(vm, {
mocks, mocks,
initRefs initRefs
}) })
appOptions.onShow = function onShow (args) {
if (!this.$vm) {
this.onLaunch(args)
}
this.$vm.__call_hook('onShow', args)
}
return appOptions
} }
...@@ -5,18 +5,18 @@ import { ...@@ -5,18 +5,18 @@ import {
initMocks initMocks
} from 'uni-wrapper/util' } from 'uni-wrapper/util'
const hooks = [ const hooks = [
'onShow', 'onShow',
'onHide', 'onHide',
'onError', 'onError',
'onPageNotFound' 'onPageNotFound'
] ]
export default function parseBaseApp (vm, { export default function parseBaseApp (vm, {
mocks, mocks,
initRefs initRefs
}) { }) {
Vue.prototype.mpHost = __PLATFORM__ Vue.prototype.mpHost = __PLATFORM__
Vue.mixin({ Vue.mixin({
beforeCreate () { beforeCreate () {
...@@ -45,6 +45,9 @@ export default function parseBaseApp (vm, { ...@@ -45,6 +45,9 @@ export default function parseBaseApp (vm, {
const appOptions = { const appOptions = {
onLaunch (args) { onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
if (__PLATFORM__ === 'mp-weixin') { if (__PLATFORM__ === 'mp-weixin') {
if (!wx.canIUse('nextTick')) { // 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断 if (!wx.canIUse('nextTick')) { // 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console.error('当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上') console.error('当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册