为什么此代码会删除<div>Content After Hook</div>
元素?
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.2/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.2/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
</head>
<body>
<script type="text/babel">
ReactDOM.render(
<span>React Content</span>,
document.getElementById('react_hook')
);
</script>
<div>Content Before Hook</div>
<div id="react_hook"/>
<div>Content After Hook</div>
</body>
</html>
&#13;
答案 0 :(得分:1)
您无法自行关闭div
代码。
所以一定是
<div id="react_hook"></div>
您当前的布局被视为已打开且未关闭div
,其中包含</body>
参考文献:
Tag omission in text/html
部分)