Skip to content

Commit

Permalink
fix: 修正后端传递组件包含正则处理错误的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
sj817 committed Feb 15, 2025
1 parent 659bf8c commit dc3a2ae
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions packages/core/src/components/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,24 @@ import type { InputProps } from '@/types/components'
const createInput = (
key: string,
config: Partial<Omit<InputProps, 'key' | 'componentType'>> = {}
): InputProps => ({
...config,
key,
componentType: 'input',
})
): InputProps => {
const data: InputProps = {
...config,
key,
componentType: 'input',
}

if (config.rules) {
data.rules = config.rules.map((rule) => {
return {
...rule,
regex: rule.regex instanceof RegExp ? rule.regex.source : rule.regex
}
})
}

return data
}

/**
* 输入框
Expand Down

0 comments on commit dc3a2ae

Please sign in to comment.