为什么JSON.stringify会产生一个空对象?
window.addEventListener("resize", updateDimensions);
function updateDimensions(){
var node = document.getElementById('sample');
var windowDimensions = {width: window.innerWidth, height: window.innerHeight};
var dimensions = node.getBoundingClientRect();
console.log('dimensions', dimensions);//dimensions is ClientRect {top: X, right: ...}
var result = ' dimensions: ' + JSON.stringify(dimensions)
+ ' windowDimensions: ' + JSON.stringify(windowDimensions);
console.log(result);//now dimensions is {}
}
<div id="output"></div>
<div id="sample">
Hello World
</div>
#sample {
padding: 20px;
max-height: 380px;
overflow-y: auto;
max-width: 150px;
border: solid blue;
margin-left: 250px;
margin-top: 100px;
}