提交 426bef31 编写于 作者: Q qiang

Merge branch 'dev' into alpha

...@@ -128,7 +128,8 @@ module.exports = function generateComponent (compilation) { ...@@ -128,7 +128,8 @@ module.exports = function generateComponent (compilation) {
} }
if (name.endsWith('.wxss')) { if (name.endsWith('.wxss')) {
// 移除部分含有错误引用的 wxss 文件 // 移除部分含有错误引用的 wxss 文件
const origSource = assets[name].source().trim() let origSource = assets[name].source()
origSource = origSource.trim ? origSource.trim() : ''
const result = origSource.match(/^@import ["'](.+?)["']$/) const result = origSource.match(/^@import ["'](.+?)["']$/)
if (result) { if (result) {
const wxssPath = path.join(path.dirname(name), result[1]) const wxssPath = path.join(path.dirname(name), result[1])
......
import Vue from 'vue' import Vue from 'vue'
const getEmitter = (function () { const getEmitter = (function () {
if (typeof getUniEmitter === 'function') {
/* eslint-disable no-undef */
return getUniEmitter
}
let Emitter let Emitter
return function getUniEmitter () { return function getUniEmitter () {
if (!Emitter) { if (!Emitter) {
......
...@@ -9,8 +9,8 @@ import { ...@@ -9,8 +9,8 @@ import {
export const PAGE_EVENT_HOOKS = [ export const PAGE_EVENT_HOOKS = [
'onPullDownRefresh', 'onPullDownRefresh',
'onReachBottom', 'onReachBottom',
'onAddToFavorites', 'onAddToFavorites',
'onShareTimeline', 'onShareTimeline',
'onShareAppMessage', 'onShareAppMessage',
'onPageScroll', 'onPageScroll',
...@@ -471,6 +471,15 @@ function isMatchEventType (eventType, optType) { ...@@ -471,6 +471,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
}
export function handleEvent (event) { export function handleEvent (event) {
event = wrapper(event) event = wrapper(event)
...@@ -503,12 +512,8 @@ export function handleEvent (event) { ...@@ -503,12 +512,8 @@ export function handleEvent (event) {
const methodName = eventArray[0] const methodName = eventArray[0]
if (methodName) { if (methodName) {
let handlerCtx = this.$vm let handlerCtx = this.$vm
if ( if (handlerCtx.$options.generic) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx.$options.generic && handlerCtx = getContextVm(handlerCtx) || handlerCtx
handlerCtx.$parent &&
handlerCtx.$parent.$parent
) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = handlerCtx.$parent.$parent
} }
if (methodName === '$emit') { if (methodName === '$emit') {
handlerCtx.$emit.apply(handlerCtx, handlerCtx.$emit.apply(handlerCtx,
...@@ -552,4 +557,4 @@ export function handleEvent (event) { ...@@ -552,4 +557,4 @@ export function handleEvent (event) {
) { ) {
return ret[0] return ret[0]
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册