react+webpack打包时模块化问题

var React = require('react');
var ReactDOM = require('react-dom');
var ProductCss = require('./css/product.css');
require('./css/product.css');
var AppComponent = require('./components/login.js');
var RankList=require('./components/ranking.js');

ReactDOM.render(<AppComponent />, document.getElementById('login-container'));

ReactDOM.render(<RankList />,document.getElementById('rank-list'));

如上面的代码,这个在main.js中render两个不同页面内容,但是<RankList />组件在页面里会报(bundle.js:1393 Uncaught Invariant Violation: _registerComponent(...): Target container is not a DOM element.),是我使用的方式不对吗,还请大神指教


慕标5832272
浏览 772回答 1
1回答

翻翻过去那场雪

Target&nbsp;container&nbsp;is&nbsp;not&nbsp;a&nbsp;DOM&nbsp;element.在&nbsp;ReactDOM.render(<RankList />,document.getElementById('rank-list'));&nbsp;这行打个断点调一下,看看页面里&nbsp;document.getElementById('rank-list')&nbsp;这个渲染容器节点是不是不存在
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript