mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-05-21 16:29:54 +08:00
feat:优化FormRender组件的事件处理逻辑,支持动态函数绑定
This commit is contained in:
@@ -46,9 +46,9 @@ const parseProps = (rawProps: Record<string, any>, model: Record<string, any>) =
|
||||
model[value] = newValue
|
||||
}
|
||||
} else if (key.startsWith('on')) {
|
||||
// 处理事件监听
|
||||
// 处理事件监听,值是函数的代码
|
||||
const eventName = key.replace('on', '').toLowerCase()
|
||||
parsedProps[eventName] = (event: any) => model[value](event)
|
||||
parsedProps[eventName] = new Function('model', `with(model) { return ${value} }`)(model)
|
||||
} else {
|
||||
// 如果是表达式,需要绑定
|
||||
if (typeof value === 'string' && value.startsWith('{{') && value.endsWith('}}')) {
|
||||
|
||||
Reference in New Issue
Block a user