简体   繁体   English

如何使用本机元素访问嵌套的阴影球离子角

[英]How to access the nested shadow-dom Ionic angular using native element

I want to access the child shadow-root inside a parent shadow-root. 我想访问父影子根内部的子影子根。

const shadow = this.el.nativeElement.attachShadow({ mode: 'open' })

The above code actually return the parent shadow-root, but i tried to access the child showdow-root using querySelector but it return null. 上面的代码实际上返回了父阴影根,但是我尝试使用querySelector访问子showdow-root,但是它返回null。

The main purpose is to change the position-top value to 44px in the ion-backdrop component which is a shadowdom inside ion-menu component. 主要目的是将在离子菜单组件内部的阴影区域的离子背景组件中的位置最高值更改为44px。 Please find below the screenshot. 请在屏幕截图下方找到。 在此处输入图片说明

I think you can't edit that property because on the official documentation for ion-backdrop there is no custom css that allows you to overwrite the standard values in the shadow dom. 我认为您无法编辑该属性,因为在ion-background官方文档中没有自定义的css可以覆盖影子dom中的标准值。 It is the clear intention that these values can't be overwritten that easy. 明确的意图是,不能轻易覆盖这些值。

But the documentation also says: Backdrops are full screen components that overlay other components. 但是文档还说: Backdrops are full screen components that overlay other components. So you might reach your goal if you nest your Backdrop in another component that fits your needs? 因此,如果将Backdrop嵌套在另一个适合您需求的组件中,您可能会达到目标? Hope that helps. 希望能有所帮助。

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

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