Refused to apply inline style because it violates the following Content Security Policy directive

后端 未结 6 2366
心在旅途
心在旅途 2020-12-08 09:08

So, in about 1 hour my extensions failed hard.

I was doing my extension and it was doing what I pretended. I made some changes, and as I didnt liked I deleted them,

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 09:48

    Another method is to use the CSSOM (CSS Object Model), via the style property on a DOM node.

    var myElem = document.querySelector('.my-selector');
    myElem.style.color = 'blue';
    

    More details on CSSOM: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement.style

    As mentioned by others, enabling unsafe-line for css is another method to solve this.

提交回复
热议问题