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

Merge branch 'dev' into alpha

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