Polymer 2.0 custom style property is not working under dom-module

狂风中的少年 提交于 2019-12-24 11:07:41

问题


I have upgraded polymer project to 2.0 version. After that some css class is missing from div.

There is a link to iron-flex-layout.html from my-home.html

<link rel="import" href="bower_components/iron-flex-layout/iron-flex-layout.html">

And in my-home.html page have some styles like following:

<dom-module id="my-home">
<template>
<style is="custom-style">
.flex-vertical {
  @apply --layout-vertical;
  height: 100vh;
}

.flexchild-vertical {
  @apply --layout-flex;
  @apply --layout-horizontal;
}
</style>
</template>
</dom-module>

These styles are calling from iron-flex-layout.html

--layout-vertical
--layout-flex
--layout-horizontal

But its not loading into my output. Here is the screenshots from my browser:

Old version:

Upgraded version:

I think the problem may because of that there is a #shadow-root generated.

Can I change style links / html links or any other in my code?


回答1:


Yes! Got the answer from here: https://www.polymer-project.org/2.0/docs/upgrade#class-based-elements-import-the-css-mixin-shim

It is the version problem with the iron-flex-layout. I just updated it and everything is fine now.

The latest version (2.0) have a <custom-style> object wrapping whole the styles inside iron-flex-layout.html

Here is the latest version: https://github.com/PolymerElements/iron-flex-layout



来源:https://stackoverflow.com/questions/46826321/polymer-2-0-custom-style-property-is-not-working-under-dom-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!