首页 > 其他分享 >Uncaught DOMException: Failed to execute 'insertRule' on 'CSSStyleSheet': Cannot

Uncaught DOMException: Failed to execute 'insertRule' on 'CSSStyleSheet': Cannot

时间:2022-08-22 10:23:02浏览次数:100  
标签:appendChild execute DOMException insertRule style cssStyle 报错

在动态的向某个元素添加动画的过程中,使用insertRule的方式插入,浏览器报错。具体报错如下:

具体原因:这篇文章说的比较清楚了

解决方案:

insertCSSRule(element,cssStyle){
    const style = document.createElement('style')
    style.appendChild(document.createTextNode(cssStyle));
    element.appendChild(style)
 }

 

标签:appendChild,execute,DOMException,insertRule,style,cssStyle,报错
From: https://www.cnblogs.com/jching/p/16611916.html

相关文章