我正在关注这个很棒的教程:setting-up-react-in-ruby-on-rails-part-1
我收到此错误:错误:无法从 xxx 找到模块 xxx
测试组件.es6.js
React = require('react/addons');
let TestTwo = require('./components/test-two.es6.js');
let TestComponent = React.createClass({
render() {
return (
<div>
<h1>{this.props.title}</h1>
<TestTwo />
</div>
);
}
});
module.exports = TestComponent;
组件.js
//= require_tree ./components
// You'll probably want this if your using babel
require("babelify/polyfill");
var app = window.app = global.app = {};
//React bootstrap modules
var TestComponent = require('./components/test-component.es6.js');
app.TestComponent = TestComponent;
当我以这种方式设置它时,它可以工作,但 TestTwo 组件没有预渲染(我使用 prerender:true)
重要编辑
在此设置内容中的服务器编辑后被预渲染,但每次在浏览器中更改数据时我都需要重新启动服务器但是当我打开源视图时旧数据没有新的!?
测试组件.es6.js
React = require('react/addons');
let TestComponent = React.createClass({
render() {
return (
<div>
<h1>{this.props.title}</h1>
<app.TestTwo />
</div>
);
}
});
module.exports = TestComponent;
组件.js
//= require_tree ./components
// You'll probably want this if your using babel
require("babelify/polyfill");
var app = window.app = global.app = {};
//React bootstrap modules
var TestTwo = require('./components/test-two.es6.js');
app.TestTwo = TestTwo;
var TestComponent = require('./components/test-component.es6.js');
app.TestComponent = TestComponent;
TestTwo 组件只是返回一些文本。
两种设置的text.html.erb相同
<%= react_component 'app.TestComponent', {title:"Hello, Back"}, {prerender:true} %>
Win7 64位操作系统