diff --git a/packages/uni-app-plus/dist/index.js b/packages/uni-app-plus/dist/index.js index 6a0625f171f4ce46f21ef876a056051ec3e2e1cb..c29ae55ba90451b87e17ad189e36f799dca7e0e1 100644 --- a/packages/uni-app-plus/dist/index.js +++ b/packages/uni-app-plus/dist/index.js @@ -470,10 +470,6 @@ TODOS.forEach(function (name) { }); const getEmitter = (function () { - if (typeof getUniEmitter === 'function') { - /* eslint-disable no-undef */ - return getUniEmitter - } let Emitter; return function getUniEmitter () { if (!Emitter) { @@ -637,8 +633,8 @@ Component = function (options = {}) { const PAGE_EVENT_HOOKS = [ 'onPullDownRefresh', - 'onReachBottom', - 'onAddToFavorites', + 'onReachBottom', + 'onAddToFavorites', 'onShareTimeline', 'onShareAppMessage', 'onPageScroll', @@ -1073,6 +1069,15 @@ function isMatchEventType (eventType, optType) { ) } +function getContextVm (vm) { + let $parent = vm.$parent; + // 父组件是 scoped slots 或者其他自定义组件时继续查找 + while ($parent && $parent.$parent && ($parent.$options.generic || $parent.$parent.$options.generic || $parent.$scope._$vuePid)) { + $parent = $parent.$parent; + } + return $parent && $parent.$parent +} + function handleEvent (event) { event = wrapper$2(event); @@ -1105,12 +1110,8 @@ function handleEvent (event) { const methodName = eventArray[0]; if (methodName) { let handlerCtx = this.$vm; - if ( - handlerCtx.$options.generic && - handlerCtx.$parent && - handlerCtx.$parent.$parent - ) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots - handlerCtx = handlerCtx.$parent.$parent; + if (handlerCtx.$options.generic) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots + handlerCtx = getContextVm(handlerCtx) || handlerCtx; } if (methodName === '$emit') { handlerCtx.$emit.apply(handlerCtx, diff --git a/packages/uni-mp-alipay/dist/index.js b/packages/uni-mp-alipay/dist/index.js index b58100687e272cdae04f0026713b72897c07b412..f4bfc5f9972b373bcc92f68a0e766ed1429528ab 100644 --- a/packages/uni-mp-alipay/dist/index.js +++ b/packages/uni-mp-alipay/dist/index.js @@ -972,10 +972,6 @@ var extraApi = /*#__PURE__*/Object.freeze({ }); const getEmitter = (function () { - if (typeof getUniEmitter === 'function') { - /* eslint-disable no-undef */ - return getUniEmitter - } let Emitter; return function getUniEmitter () { if (!Emitter) { @@ -1124,8 +1120,8 @@ var api = /*#__PURE__*/Object.freeze({ const PAGE_EVENT_HOOKS = [ 'onPullDownRefresh', - 'onReachBottom', - 'onAddToFavorites', + 'onReachBottom', + 'onAddToFavorites', 'onShareTimeline', 'onShareAppMessage', 'onPageScroll', @@ -1550,6 +1546,15 @@ function isMatchEventType (eventType, optType) { ) } +function getContextVm (vm) { + let $parent = vm.$parent; + // 父组件是 scoped slots 或者其他自定义组件时继续查找 + while ($parent && $parent.$parent && ($parent.$options.generic || $parent.$parent.$options.generic || $parent.$scope._$vuePid)) { + $parent = $parent.$parent; + } + return $parent && $parent.$parent +} + function handleEvent (event) { event = wrapper$1(event); @@ -1582,12 +1587,8 @@ function handleEvent (event) { const methodName = eventArray[0]; if (methodName) { let handlerCtx = this.$vm; - if ( - handlerCtx.$options.generic && - handlerCtx.$parent && - handlerCtx.$parent.$parent - ) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots - handlerCtx = handlerCtx.$parent.$parent; + if (handlerCtx.$options.generic) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots + handlerCtx = getContextVm(handlerCtx) || handlerCtx; } if (methodName === '$emit') { handlerCtx.$emit.apply(handlerCtx, diff --git a/packages/uni-mp-baidu/dist/index.js b/packages/uni-mp-baidu/dist/index.js index 662c9e82b12d75ea7eb7f4e05a96db98e4697f51..74b76fea6cf43722e120269205ef0e83c42bd17d 100644 --- a/packages/uni-mp-baidu/dist/index.js +++ b/packages/uni-mp-baidu/dist/index.js @@ -650,10 +650,6 @@ var extraApi = /*#__PURE__*/Object.freeze({ }); const getEmitter = (function () { - if (typeof getUniEmitter === 'function') { - /* eslint-disable no-undef */ - return getUniEmitter - } let Emitter; return function getUniEmitter () { if (!Emitter) { @@ -753,8 +749,8 @@ Component = function (options = {}) { const PAGE_EVENT_HOOKS = [ 'onPullDownRefresh', - 'onReachBottom', - 'onAddToFavorites', + 'onReachBottom', + 'onAddToFavorites', 'onShareTimeline', 'onShareAppMessage', 'onPageScroll', @@ -1215,6 +1211,15 @@ function isMatchEventType (eventType, optType) { ) } +function getContextVm (vm) { + let $parent = vm.$parent; + // 父组件是 scoped slots 或者其他自定义组件时继续查找 + while ($parent && $parent.$parent && ($parent.$options.generic || $parent.$parent.$options.generic || $parent.$scope._$vuePid)) { + $parent = $parent.$parent; + } + return $parent && $parent.$parent +} + function handleEvent (event) { event = wrapper$1(event); @@ -1247,12 +1252,8 @@ function handleEvent (event) { const methodName = eventArray[0]; if (methodName) { let handlerCtx = this.$vm; - if ( - handlerCtx.$options.generic && - handlerCtx.$parent && - handlerCtx.$parent.$parent - ) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots - handlerCtx = handlerCtx.$parent.$parent; + if (handlerCtx.$options.generic) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots + handlerCtx = getContextVm(handlerCtx) || handlerCtx; } if (methodName === '$emit') { handlerCtx.$emit.apply(handlerCtx, diff --git a/packages/uni-mp-qq/dist/index.js b/packages/uni-mp-qq/dist/index.js index 8bf2651ef688a458857a7abb83633376c056e006..bd2aad7b201e0ddf189c5c7954506cdc112a8aed 100644 --- a/packages/uni-mp-qq/dist/index.js +++ b/packages/uni-mp-qq/dist/index.js @@ -611,10 +611,6 @@ var extraApi = /*#__PURE__*/Object.freeze({ }); const getEmitter = (function () { - if (typeof getUniEmitter === 'function') { - /* eslint-disable no-undef */ - return getUniEmitter - } let Emitter; return function getUniEmitter () { if (!Emitter) { @@ -695,8 +691,8 @@ Component = function (options = {}) { const PAGE_EVENT_HOOKS = [ 'onPullDownRefresh', - 'onReachBottom', - 'onAddToFavorites', + 'onReachBottom', + 'onAddToFavorites', 'onShareTimeline', 'onShareAppMessage', 'onPageScroll', @@ -1131,6 +1127,15 @@ function isMatchEventType (eventType, optType) { ) } +function getContextVm (vm) { + let $parent = vm.$parent; + // 父组件是 scoped slots 或者其他自定义组件时继续查找 + while ($parent && $parent.$parent && ($parent.$options.generic || $parent.$parent.$options.generic || $parent.$scope._$vuePid)) { + $parent = $parent.$parent; + } + return $parent && $parent.$parent +} + function handleEvent (event) { event = wrapper$1(event); @@ -1163,12 +1168,8 @@ function handleEvent (event) { const methodName = eventArray[0]; if (methodName) { let handlerCtx = this.$vm; - if ( - handlerCtx.$options.generic && - handlerCtx.$parent && - handlerCtx.$parent.$parent - ) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots - handlerCtx = handlerCtx.$parent.$parent; + if (handlerCtx.$options.generic) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots + handlerCtx = getContextVm(handlerCtx) || handlerCtx; } if (methodName === '$emit') { handlerCtx.$emit.apply(handlerCtx, diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js index b85d9bb243ba8731758a7434a4c322e89baa5a8f..e2cea6b7caff8008e3e4c9d4674813441bd56922 100644 --- a/packages/uni-mp-toutiao/dist/index.js +++ b/packages/uni-mp-toutiao/dist/index.js @@ -703,10 +703,6 @@ var extraApi = /*#__PURE__*/Object.freeze({ }); const getEmitter = (function () { - if (typeof getUniEmitter === 'function') { - /* eslint-disable no-undef */ - return getUniEmitter - } let Emitter; return function getUniEmitter () { if (!Emitter) { @@ -787,8 +783,8 @@ Component = function (options = {}) { const PAGE_EVENT_HOOKS = [ 'onPullDownRefresh', - 'onReachBottom', - 'onAddToFavorites', + 'onReachBottom', + 'onAddToFavorites', 'onShareTimeline', 'onShareAppMessage', 'onPageScroll', @@ -1223,6 +1219,15 @@ function isMatchEventType (eventType, optType) { ) } +function getContextVm (vm) { + let $parent = vm.$parent; + // 父组件是 scoped slots 或者其他自定义组件时继续查找 + while ($parent && $parent.$parent && ($parent.$options.generic || $parent.$parent.$options.generic || $parent.$scope._$vuePid)) { + $parent = $parent.$parent; + } + return $parent && $parent.$parent +} + function handleEvent (event) { event = wrapper$1(event); @@ -1255,12 +1260,8 @@ function handleEvent (event) { const methodName = eventArray[0]; if (methodName) { let handlerCtx = this.$vm; - if ( - handlerCtx.$options.generic && - handlerCtx.$parent && - handlerCtx.$parent.$parent - ) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots - handlerCtx = handlerCtx.$parent.$parent; + if (handlerCtx.$options.generic) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots + handlerCtx = getContextVm(handlerCtx) || handlerCtx; } if (methodName === '$emit') { handlerCtx.$emit.apply(handlerCtx, diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js index 17b2b6602c6729d4f780c13da1d0ff6de258aefc..6257f15b65c624c832709d3fe2b467f49582f813 100644 --- a/packages/uni-mp-weixin/dist/index.js +++ b/packages/uni-mp-weixin/dist/index.js @@ -563,10 +563,6 @@ var extraApi = /*#__PURE__*/Object.freeze({ }); const getEmitter = (function () { - if (typeof getUniEmitter === 'function') { - /* eslint-disable no-undef */ - return getUniEmitter - } let Emitter; return function getUniEmitter () { if (!Emitter) { @@ -652,8 +648,8 @@ Component = function (options = {}) { const PAGE_EVENT_HOOKS = [ 'onPullDownRefresh', - 'onReachBottom', - 'onAddToFavorites', + 'onReachBottom', + 'onAddToFavorites', 'onShareTimeline', 'onShareAppMessage', 'onPageScroll', @@ -1088,6 +1084,15 @@ function isMatchEventType (eventType, optType) { ) } +function getContextVm (vm) { + let $parent = vm.$parent; + // 父组件是 scoped slots 或者其他自定义组件时继续查找 + while ($parent && $parent.$parent && ($parent.$options.generic || $parent.$parent.$options.generic || $parent.$scope._$vuePid)) { + $parent = $parent.$parent; + } + return $parent && $parent.$parent +} + function handleEvent (event) { event = wrapper$1(event); @@ -1120,12 +1125,8 @@ function handleEvent (event) { const methodName = eventArray[0]; if (methodName) { let handlerCtx = this.$vm; - if ( - handlerCtx.$options.generic && - handlerCtx.$parent && - handlerCtx.$parent.$parent - ) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots - handlerCtx = handlerCtx.$parent.$parent; + if (handlerCtx.$options.generic) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots + handlerCtx = getContextVm(handlerCtx) || handlerCtx; } if (methodName === '$emit') { handlerCtx.$emit.apply(handlerCtx, diff --git a/packages/uni-quickapp-webview/dist/index.js b/packages/uni-quickapp-webview/dist/index.js index 43dbdb56d53fb6145ae7ec4a259341aac1bc89ee..22e115daf7d5533233362ab08ef970b6231cf7b7 100644 --- a/packages/uni-quickapp-webview/dist/index.js +++ b/packages/uni-quickapp-webview/dist/index.js @@ -553,10 +553,6 @@ var extraApi = /*#__PURE__*/Object.freeze({ }); const getEmitter = (function () { - if (typeof getUniEmitter === 'function') { - /* eslint-disable no-undef */ - return getUniEmitter - } let Emitter; return function getUniEmitter () { if (!Emitter) { @@ -637,8 +633,8 @@ Component = function (options = {}) { const PAGE_EVENT_HOOKS = [ 'onPullDownRefresh', - 'onReachBottom', - 'onAddToFavorites', + 'onReachBottom', + 'onAddToFavorites', 'onShareTimeline', 'onShareAppMessage', 'onPageScroll', @@ -1073,6 +1069,15 @@ function isMatchEventType (eventType, optType) { ) } +function getContextVm (vm) { + let $parent = vm.$parent; + // 父组件是 scoped slots 或者其他自定义组件时继续查找 + while ($parent && $parent.$parent && ($parent.$options.generic || $parent.$parent.$options.generic || $parent.$scope._$vuePid)) { + $parent = $parent.$parent; + } + return $parent && $parent.$parent +} + function handleEvent (event) { event = wrapper$1(event); @@ -1105,12 +1110,8 @@ function handleEvent (event) { const methodName = eventArray[0]; if (methodName) { let handlerCtx = this.$vm; - if ( - handlerCtx.$options.generic && - handlerCtx.$parent && - handlerCtx.$parent.$parent - ) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots - handlerCtx = handlerCtx.$parent.$parent; + if (handlerCtx.$options.generic) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots + handlerCtx = getContextVm(handlerCtx) || handlerCtx; } if (methodName === '$emit') { handlerCtx.$emit.apply(handlerCtx,