util.uts 473 字节
Newer Older
M
mehaotian 已提交
1 2 3 4 5 6 7 8 9 10 11 12
// 查找父组件实例
export function $dispatch(
	context : ComponentPublicInstance,
	componentName : string,
	eventName : string,
	...params : any | null
) {
	let parent = context.$parent
	let name = parent?.$options?.name
	while (parent != null && (name == null || componentName != name)) {
		parent = parent.$parent
		if (parent != null) {
Y
yurj26 已提交
13
			name = parent.$options.name
M
mehaotian 已提交
14 15 16 17 18
		}
	}
	if (parent != null) {
		parent.$callMethod(eventName, ...params)
	}
Y
yurj26 已提交
19
}