Skip to content

Commit

Permalink
fix: 处理输出支付宝事件首字母大小写问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackgan3 committed Feb 6, 2025
1 parent d1c5506 commit 3e0fc11
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/webpack-plugin/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ module.exports = {
}
},
getEvent (eventName, prefix = 'on') {
return dash2hump(prefix + '-' + eventName)
return prefix + dash2hump(eventName.replace(/^./, (matched) => {
return matched.toUpperCase()
}))
},
defaultModelProp: 'value',
defaultModelEvent: 'input',
Expand Down
4 changes: 3 additions & 1 deletion packages/webpack-plugin/lib/platform/template/wx/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ module.exports = function getSpec ({ warn, error }) {
const rPrefix = runRules(spec.event.prefix, prefix, { mode: 'ali' })
const rEventName = runRules(eventRules, eventName, { mode: 'ali' })
return {
name: dash2hump(rPrefix + '-' + rEventName) + modifierStr,
name: rPrefix + dash2hump(rEventName.replace(/^./, (matched) => {
return matched.toUpperCase()
})) + modifierStr,
value
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack-plugin/lib/utils/hump-dash.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
})
},
dash2hump (value) {
return value.replace(/-([a-z])/ig, function (match, p1) {
return value.replace(/-([a-z])/g, function (match, p1) {
return p1.toUpperCase()
})
}
Expand Down

0 comments on commit 3e0fc11

Please sign in to comment.