mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 07:28:37 +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
|
model[value] = newValue
|
||||||
}
|
}
|
||||||
} else if (key.startsWith('on')) {
|
} else if (key.startsWith('on')) {
|
||||||
// 处理事件监听
|
// 处理事件监听,值是函数的代码
|
||||||
const eventName = key.replace('on', '').toLowerCase()
|
const eventName = key.replace('on', '').toLowerCase()
|
||||||
parsedProps[eventName] = (event: any) => model[value](event)
|
parsedProps[eventName] = new Function('model', `with(model) { return ${value} }`)(model)
|
||||||
} else {
|
} else {
|
||||||
// 如果是表达式,需要绑定
|
// 如果是表达式,需要绑定
|
||||||
if (typeof value === 'string' && value.startsWith('{{') && value.endsWith('}}')) {
|
if (typeof value === 'string' && value.startsWith('{{') && value.endsWith('}}')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user