我们在我们的站点上使用WebComponents和Polymer,并且有相当多的Javascript在执行之前等待"WebComponentsReady"事件被触发。然而,我们有一些异步JS文件,它们偶尔会在事件被触发后添加一个事件监听器,这意味着我们想要运行的脚本永远不会运行。有谁知道是否有可以检查的Web组件准备就绪标志?我们需要这样的东西:if(WebComponents.ready){//Doesthisflag,orsomethingsimilar,exist??//dostuff}else{document.addEventListener('WebComponentsRe
根据Polymerdocs,WebComponentsReady事件是必需的,因为...Thepolyfillsparseelementdefinitionsandhandletheirupgradeasynchronously.IfyouprematurelyfetchtheelementfromtheDOMbeforeithasachancetoupgrade,you’llbeworkingwithanHTMLUnknownElement.Inthesesituations,waitfortheWebComponentsReadyeventbeforeinteractingwith
根据Polymerdocs,WebComponentsReady事件是必需的,因为...Thepolyfillsparseelementdefinitionsandhandletheirupgradeasynchronously.IfyouprematurelyfetchtheelementfromtheDOMbeforeithasachancetoupgrade,you’llbeworkingwithanHTMLUnknownElement.Inthesesituations,waitfortheWebComponentsReadyeventbeforeinteractingwith