How to dynamically change style through js

1. Introduce scss
2. Define global variables in the global scss file
Insert image description here
3. Reference variables and change variable values
Insert image description here
Insert image description here

document.getElementsByTagName('body')[0].style.setProperty('--color','#fff')

Okay, I believe you are smart and have understood it.

Guess you like

Origin blog.csdn.net/qq_17355709/article/details/127980070