element.style返回html文档中使用的内联样式,由于该样式不是直接在html中设置的,因此您将获得且值为空
您正在寻找的是computeedStyle,它将返回应用于元素的样式
console.log(window.getComputedStyle(document.getElementById('test')).display)#map { display: block; align-content:center; }<div id="test">test</div>


