根据他们的演示,我已经努力了几个小时才能对金色布局做出反应:
http://golden-layout.com/examples/#XdabGJ
我正在使用电子创建一个文档编辑应用程序,并尝试使用 gl 来提供文档的虚拟视图。我希望每个 gl 窗口都托管一个反应组件。我创建了以下类:
[变量列表.js]
const React = require('react')
const Component = React.Component
class VariableList extends Component {
constructor() {
super()
this.state = { }
}
render() {
console.log('render')
return (
<div className="variable-list">
<h3>Variables</h3>
</div>
);
}
}
module.exports = VariableList;
我从我的主脚本中引用:
const GoldenLayout = require('golden-layout');
const VariableList = require('variable-list')
var config = {
content: [{
type: 'column',
content: [{
type: 'component',
componentName: 'variables'
}]
}]
};
// Setup layout
var layout = new GoldenLayout(config);
layout.registerComponent( 'variables', VariableList );
layout.init();
当我运行代码时,会创建 gl 并出现一个窗口,但其中不包含任何元素,并且控制台不包含预期的打印。
这些示例显示了通过“React.createClass”创建的类,但是该函数似乎不再存在,并且根据反应文档,“扩展组件”与它类似。
如何让 gl 调用我的渲染函数?