Skip to content

Commit

Permalink
feat(taro): 改进事件处理函数不存在时的错误提示, close NervJS#2600
Browse files Browse the repository at this point in the history
  • Loading branch information
vimcaw committed Mar 27, 2019
1 parent 2a8224e commit a820fb9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion packages/taro-alipay/src/create-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ function processEvent (eventHandlerName, obj) {
}
realArgs = [...datasetArgs, event]
}
return scope[eventHandlerName].apply(callScope, realArgs)
if (scope[eventHandlerName]) {
return scope[eventHandlerName].apply(callScope, realArgs)
} else {
throw `事件处理函数${eventHandlerName}不存在`
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion packages/taro-swan/src/create-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ function processEvent (eventHandlerName, obj) {
}
realArgs = [_scope, ...datasetArgs, ...detailArgs, event]
}
return scope[eventHandlerName].apply(callScope, realArgs)
if (scope[eventHandlerName]) {
return scope[eventHandlerName].apply(callScope, realArgs)
} else {
throw `事件处理函数${eventHandlerName}不存在`
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion packages/taro-tt/src/create-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ function processEvent (eventHandlerName, obj) {
}
realArgs = [_scope, ...datasetArgs, ...detailArgs, event]
}
return scope[eventHandlerName].apply(callScope, realArgs)
if (scope[eventHandlerName]) {
return scope[eventHandlerName].apply(callScope, realArgs)
} else {
throw `事件处理函数${eventHandlerName}不存在`
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion packages/taro-weapp/src/create-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ function processEvent (eventHandlerName, obj) {
}
realArgs = [_scope, ...datasetArgs, ...detailArgs, event]
}
return scope[eventHandlerName].apply(callScope, realArgs)
if (scope[eventHandlerName]) {
return scope[eventHandlerName].apply(callScope, realArgs)
} else {
throw `事件处理函数${eventHandlerName}不存在`
}
}
}

Expand Down

0 comments on commit a820fb9

Please sign in to comment.