I tried different ways for this problem, but each had problems.
For example, when I use getComputedStyle, when I want to get a background or background-color value, I get the value null or rgb, which is really annoying. Once I use element.style, the css value that is not recorded returns to null
window.getComputedStyle(document.querySelector("#example"),null).getPropertyValue('background-color'); //return rgb
window.getComputedStyle(document.querySelector("#example"),null).getPropertyValue('background'); //return null
document.querySelector("#example").style.backgroundColor; //If the value is not set, returns empty