小编Dan*_*lue的帖子

跨元素的聚合物共享样式

我需要在多个Polymer元素之间共享样式。创建“ styles.html”文件然后将其导入到我的其他元素中是否可以接受,还是随着应用程序的增长而开始对性能产生影响?我知道有0.5种核心样式,但是如果导入也能正常工作的话,这似乎是不必要的。

styles.html

<style>
  button {
    background: red;
  }
</style>
Run Code Online (Sandbox Code Playgroud)

my-button.html

<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../styles/main-styles.html">
<link rel="import" href="../behaviors/mixins.html">

<dom-module id="my-button">
  <template>
    <button>{{text}}</button>
  </template>
</dom-module>

<script>
  Polymer({
    is: 'my-button',
    behaviors: [ButtonBehavior]
  })
</script>
Run Code Online (Sandbox Code Playgroud)

javascript css shadow-dom polymer

4
推荐指数
1
解决办法
2940
查看次数

标签 统计

css ×1

javascript ×1

polymer ×1

shadow-dom ×1