简体   繁体   English

子组件可以使用 updateRoot: 添加 javascript

[英]Can a child component use updateRoot: to add javascript

I'm using seaside 3.4.8 and a component seaside-plotlyjs to make a javascript plot. This component uses the updateRoot: selector to add in a link to the plotly javascript bundle.我正在使用 seaside 3.4.8 和组件seaside-plotlyjs制作 javascript plot。此组件使用updateRoot:选择器添加指向 plotly javascript 包的链接。 Everything is fine until I make the component a child of another component, in which case the plotly library is no longer added to the site.一切都很好,直到我使该组件成为另一个组件的子组件,在这种情况下,不再将 plotly 库添加到该站点。 If I take the contents of the updateRoot: selector and move it into the root component, then it works again.如果我获取updateRoot:选择器的内容并将其移动到根组件中,那么它会再次运行。 Is it possible to have the updateRoot: selector be independent of whether my component is the root or a child of another one to improve the composability of my components?是否可以让updateRoot:选择器独立于我的组件是根组件还是另一个组件的子组件以提高组件的可组合性?

ChildComponent>>updateRoot:

updateRoot: anHtmlRoot

super updateRoot: anHtmlRoot.
anHtmlRoot javascript url: 'https://cdn.plot.ly/plotly-2.4.2.min.js'

RootComponent>>updateRoot:

updateRoot: anHtmlRoot

super updateRoot: anHtmlRoot.

anHtmlRoot stylesheet url:
    'https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css'.
anHtmlRoot stylesheet url:
    'https://cdnjs.cloudflare.com/ajax/libs/milligram/1.4.1/milligram.css'.

Did you implement a children method on RootComponent that returns the child component?您是否在RootComponent上实现了返回子组件的children方法?

Seaside will use the result of the children method to know the component tree. Seaside 将使用children方法的结果来了解组件树。 A common mistake is to forget this method as many parts of Seaside work just fine without it returning all child component instances.一个常见的错误是忘记了这个方法,因为 Seaside 的许多部分在没有返回所有子组件实例的情况下工作得很好。

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

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