简体   繁体   English

聚合物中的 ::part() 与 Microsoft-Edge 不兼容

[英]::part() in polymer is not compatible with Microsoft-Edge

I am developing a web-component project based on polymer 2.0.我正在开发一个基于聚合物 2.0 的网络组件项目。 I am using the part concept in polymer to differentiate different aspect of an element.我在聚合物中使用零件概念来区分元素的不同方面。 Since I need different style to a specific part, I am applying style to this specific part using ::part() after importing this to other HTML files.由于我需要对特定部分使用不同的样式,因此在将其导入其他 HTML 文件后,我使用 ::part() 将样式应用于此特定部分。

Sample code is as followed.示例代码如下。

<customElement>
<div part="samplePart">
demo
</div>
//other tags
</customElement>

And style element is as followed.样式元素如下。

customElement::part(samplePart){
//some styles
}

This approach is working fine in google chrome.这种方法在谷歌浏览器中运行良好。 But the problem is that when I am using Microsoft-edge browser, it is not reading the "part" element and applying whatever default style to the whole element.但问题是,当我使用 Microsoft-edge 浏览器时,它没有读取“部分”元素并将任何默认样式应用于整个元素。

Any idea how to achieve this in Edge?知道如何在 Edge 中实现这一点吗? I do not prefer changing the HTML part as I am importing this element to multiple independent files which need different styling.我不喜欢更改 HTML 部分,因为我将此元素导入到需要不同样式的多个独立文件中。

According to the polymer document , I create a sample and test the code, I could reproduce the problem, but from the official document and polymer issues , I'm not finding the solution for this issue, I suggest you could contact polymer team or post this issue to the polymer issues .根据聚合物文档,我创建了一个示例并测试了代码,我可以重现该问题,但是从官方文档和聚合物问题中,我没有找到此问题的解决方案,建议您可以联系聚合物团队或发帖这个问题就聚合物问题

As a workaround, you could try to use the following code to add css style for the samplePart:作为一种解决方法,您可以尝试使用以下代码为 samplePart 添加 css 样式:

customElement > div[part='samplePart'] {
    width: 200px;
    height: 200px;
    background-color: antiquewhite
}

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

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