等待dom准备好不使用 [英] Wait for dom ready without useShadowDom

查看:97
本文介绍了等待dom准备好不使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想等到我的组件完全加载好之后.当前的方法是实现ShadowRootAware接口.但是,如果该组件禁用了阴影dom,则此方法将不起作用:

I want to wait until my component is fully loaded. The current approach would be to implement the ShadowRootAware interface. However this does not work, if the component disables the use of shadow dom:

@Component(
    selector: 'travel-step',
    templateUrl: 'packages/TravelPlanner/travelstep/travel_step_component.html',
    useShadowDom: false,
    publishAs: 'cmp')
class TravelStepComponent extends AttachAware{

我需要禁用ShadowDom,因为我想使用父对象(例如Bootstrap)中的样式.还有另一种方式来等待dom准备好吗?

I need to disable the usage of ShadowDom, because I want to use styles from my parent object (e.g. Bootstrap). Is there another way to wait for the dom to be ready?

我想引用文件上传输入.目前(角度v.012),似乎没有其他方法可以上传文件.

I want to reference a file upload input. At the moment (angular v.012) there seems to be no other way to upload a file.

推荐答案

您可以实现ShadowRootAware接口.例如:

You can implement ShadowRootAware interface. For example:

class NgFreeTree implements ShadowRootAware { 
  void onShadowRoot(ShadowRoot shadowRoot) { ... }
}

无论useShadowDom属性如何,它都应该起作用.

It should work regardless of useShadowDom attribute.

这篇关于等待dom准备好不使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆