Rails,React,Browserify,react-rails gem - 找不到模块

时间:2015-08-15 12:39:07

标签: ruby-on-rails reactjs browserify react-rails browserify-rails

我正在关注这个很棒的教程:setting-up-react-in-ruby-on-rails-part-1

我收到此错误:错误:无法从xxx找到模块xxx

测试component.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;

component.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)

重要编辑

  

在此设置内容中进行服务器编辑后获取预渲染但我需要每次在浏览器中更改数据时重新启动服务器,但是当我打开Source View时,旧数据不是新的!?。

测试component.es6.js

React   = require('react/addons');

let TestComponent = React.createClass({
render() {
return (
  <div>
    <h1>{this.props.title}</h1>
    <app.TestTwo />
  </div>

);
}
});
module.exports = TestComponent;

component.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位操作系统

0 个答案:

没有答案