Skip to content

Commit

Permalink
fix(taro-weapp): 合并props函数执行(自定义事件传递)过程的的参数丢失
Browse files Browse the repository at this point in the history
  • Loading branch information
Simbachen committed Jul 25, 2018
1 parent ff56ffa commit b750aba
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/taro-weapp/src/create-component.js
Expand Up @@ -35,6 +35,7 @@ function processEvent (eventHandlerName, obj) {
const isAnonymousFn = eventHandlerName.indexOf(anonymousFnNamePreffix) > -1
let realArgs = []
let detailArgs = []
let datasetArgs = []
// 解析从dataset中传过来的参数
const dataset = event.currentTarget.dataset
const bindArgs = {}
Expand Down Expand Up @@ -68,11 +69,11 @@ function processEvent (eventHandlerName, obj) {
detailArgs.shift()
}
if (!isEmptyObject(bindArgs)) {
realArgs = Object.keys(bindArgs)
datasetArgs = Object.keys(bindArgs)
.sort()
.map(key => bindArgs[key]).concat(detailArgs)
.map(key => bindArgs[key])
}
realArgs.push(event)
realArgs = [...datasetArgs, ...detailArgs, event]
} else {
// 匿名函数,会将scope作为第一个参数
let _scope = null
Expand All @@ -87,11 +88,11 @@ function processEvent (eventHandlerName, obj) {
detailArgs.shift()
}
if (!isEmptyObject(bindArgs)) {
realArgs = Object.keys(bindArgs)
datasetArgs = Object.keys(bindArgs)
.sort()
.map(key => bindArgs[key]).concat(detailArgs)
.map(key => bindArgs[key])
}
realArgs = [callScope || _scope, ...realArgs, event]
realArgs = [callScope || _scope, ...datasetArgs, ...detailArgs, event]
}
scope[eventHandlerName].apply(callScope, realArgs)
}
Expand Down

0 comments on commit b750aba

Please sign in to comment.