<link rel="stylesheet" href="https://at.alicdn.com/t/c/font_1826665_p96ije5uc2f.css" crossorigin>
var linkStyle = document.getElementsByTagName("link")[0];
var sheet = linkStyle.sheet || linkStyle.styleSheet;
let reg = /(\S{1,})::before$/i
const oBody = document.body
Array.prototype.forEach.call(sheet.cssRules, rule => {
if (rule.selectorText && rule.selectorText !== '.iconfont') {
const oI = document.createElement('i')
oI.classList.add('iconfont')
oI.classList.add(reg.exec(rule.selectorText)[1].slice(1))
oBody.appendChild(oI)
}
})
标签:sheet,读取,oI,selectorText,rule,js,link
From: https://www.cnblogs.com/isAyi/p/17753402.html