Css 如何在2.0中动态导入样式表
我想导入包含变量的样式表:Css 如何在2.0中动态导入样式表,css,import,polymer,polymer-2.x,Css,Import,Polymer,Polymer 2.x,我想导入包含变量的样式表: <dom-module id="colors-palette"> <template> <style> :host { --dark-gray: #263238; --light-gray: #e6ebed; --light-blue: #00bcd4; --autovision-blue: #174291; --backgro
<dom-module id="colors-palette">
<template>
<style>
:host {
--dark-gray: #263238;
--light-gray: #e6ebed;
--light-blue: #00bcd4;
--autovision-blue: #174291;
--background-box-number-applications: red;
--color-box-number-applications: orange;
}
</style>
</template>
</dom-module>
当我的应用程序准备就绪时,我会检测到主题,然后我会尝试在就绪功能中导入我的样式,如下所示:
Polymer.importHref(this.resolveUrl('../themes/' + this.getCurrentTheme() + '/colors-palette.html'));
已加载该文件,但my-app.html中样式中的变量未更改:
app-header {
background-color: var(--dark-gray);
}
我在控制台中发现了这个错误:
在名为“颜色调色板”的模块中找不到样式数据
有什么想法吗?或者也许我必须做别的
非常感谢您的
颜色调色板.html
应该只包含为html全局设置的样式
<custom-style>
<style is="custom-style">
html {
--dark-gray: #263238;
--light-gray: #e6ebed;
--light-blue: #00bcd4;
--autovision-blue: #174291;
--background-box-number-applications: red;
--color-box-number-applications: orange;
}
</style>
</custom-style>
html{
--深灰色:#263238;
--浅灰色:#e6ebed;
--浅蓝色:#00bcd4;
--自动视觉蓝色:174291;
--背景框编号:红色;
--色盒编号应用:橙色;
}
<custom-style>
<style is="custom-style">
html {
--dark-gray: #263238;
--light-gray: #e6ebed;
--light-blue: #00bcd4;
--autovision-blue: #174291;
--background-box-number-applications: red;
--color-box-number-applications: orange;
}
</style>
</custom-style>