mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-27 05:00:48 +08:00
26 lines
662 B
JavaScript
26 lines
662 B
JavaScript
export default {
|
|
methods: {
|
|
bubbleCall (componentName, functionName, ...params) {
|
|
let parent = this.$parent || this.$root
|
|
while (true) {
|
|
if (parent) {
|
|
const name = parent.$options.name
|
|
if (Array.isArray(componentName)) {
|
|
if (componentName.includes(name)) {
|
|
parent[functionName](...params)
|
|
break
|
|
}
|
|
} else {
|
|
if (name === componentName) {
|
|
parent[functionName](...params)
|
|
break
|
|
}
|
|
}
|
|
}
|
|
if (!parent || parent === this.$root) break
|
|
parent = parent.$parent
|
|
}
|
|
}
|
|
}
|
|
}
|