简体   繁体   English

Figma 访问主组件

[英]Figma access master components

Is there a way to traverse through masterComponents without having an instance in the document first?有没有办法在没有文档中首先有实例的情况下遍历masterComponents

Also, will a component's UUID change when the component is updated, and will that UUID be the same across all consumers of that component?此外,当组件更新时,组件的 UUID 是否会发生变化,并且该 UUID 在该组件的所有使用者中是否相同?

Figured it out.弄清楚了。 Wrote a utility function for it为它写了一个实用程序 function

export function traverse(node: any) {
    if ("children" in node) {
        if (node.type !== "INSTANCE") {
            for (const child of node.children) {
                traverse(child)
                if (child.mainComponent) {
                    console.log(`name: ${child.mainComponent.name}`)
                    console.log(`key: ${child.mainComponent.key}`)
                }
            }
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM