我试图使用流路由器与反应在流星。该路线的定义如下:
FlowRouter.route('/',
{
action(){
const containerElement = document.getElementById("react-root");
if (containerElement) {
const app = React.createElement("<App/>");
ReactDOM.render(app, containerElement);
} else {
console.log("no element react-root found");
}
}
})HTML是非常基本的:
<head>
<title>Todo List</title>
</head>
<body>
<div id="react-root">react-root</div>
</body>当我启动流星并导航到localhost:3000时,页面上有react-root,控制台中有消息no element react-root found。
我试图在Meteor.startup(中包装路由定义,但随后我得到一个错误,即没有定义路由/。
发布于 2015-12-15 14:08:33
据阿鲁诺达的这句话说:
现在,Flow路由器不再等待DOM。我们在布局层中这样做。
因此,在选择使用反应布局或火焰布置之前,只有在加载DOM时才能像这样包装代码以触发代码:
FlowRouter.route('/',
{
action(){
$(function () {
const containerElement = document.getElementById("react-root");
if (containerElement) {
const app = React.createElement("<App/>");
ReactDOM.render(app, containerElement);
} else {
console.log("no element react-root found");
}
});
}
})https://stackoverflow.com/questions/34290716
复制相似问题