赞
踩
- function loadCSS(cssFile) {
- var link = document.createElement("link");
- link.rel = "stylesheet";
- link.type = "text/css";
- link.href = cssFile;
- document.head.appendChild(link);
- }
- // 异步加载CSS文件
- loadCSS('path/to/your.css');
- function loadCSSCode(cssCode) {
- var style = document.createElement('style');
- style.type = 'text/css';
- if (style.styleSheet) {
- // This is required for IE8 and below.
- style.styleSheet.cssText = cssCode;
- } else {
- style.appendChild(document.createTextNode(cssCode));
- }
- document.getElementsByTagName("head")[0].appendChild(style);
- }
- // 动态加载CSS代码
- loadCSSCode('.classname { color: red; }');
import('./path/to/your.css').then(css => css.default);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。