当我注意到我无法解释的差异时,我试图弄清楚如何使用ReactJS在元素之间应用水平空间。
下面的SSCCE :(也在jsfiddle)
<!doctype html>
<html>
<body>
<span>foo</span>
<span style='display:inline-block; width:30px'></span>
<span>bar</span>
<div id='div0'></div>
<script src="https://cdn.jsdelivr.net/react/0.14.0-rc1/react.js"> </script>
<script src="https://cdn.jsdelivr.net/react/0.14.0-rc1/react-dom.js"></script>
<script type='text/javascript'>
var rce = React.createElement.bind(React);
var x = (rce('div', {}
, rce('span', {}, 'foo')
, rce('span', {style: {display: 'inline-block', width: '30px'}})
, rce('span', {}, 'bar')));
ReactDOM.render(x, document.getElementById('div0'));
</script>
</body>
</html>
以上代码在输出上生成:
鉴于DOM元素相同(除了data-reactid
属性的存在):
为什么间距会出现这种差异?
答案 0 :(得分:2)