为什么这样不行?
发布于 7 年前 作者 yxu 5577 次浏览 来自 官方Issues

components/ancestor.js (ancestor-component):

Component({
    relations: {
        "./descendant": {
            type: "descendant",
            linked() {
                console.log("linked");
            }
        }
    }
});

components/component.wxml (some-component):

<ancestor-component>
    <slot />
</ancestor-component>

components/descendant.js (descendant-component):

Component({
    relations: {
        "./ancestor": {
            type: "ancestor"
        }
    }
});

index.wxml:

<some-component>
    <descendant-component />
</some-component>
回到顶部