我有一个组件,它代表一个页面,其中有多个SectionHeader 组件作为该页面的子组件。我想通过检查 Page 的子项(SectionHeaders)来动态创建目录。
<Page>
<TaleOfContents sections={this.props.children} />
<SectionHeader title={"Section A"} />
<TextBlock>
<p> Text here. </p>
</TextBlock>
<SectionHeader title={"Section B"} />
<TextBlock>
<p> Text here. </p>
</TextBlock>
</Page>
Run Code Online (Sandbox Code Playgroud)
不幸的是,this.props.children未定义。有没有办法动态获取 Page 的这些子项并将它们呈现在 TableOfContents 中?
编辑:这是我的页面组件。它实际上只是一个将一堆其他组件捆绑在一起的大型渲染方法。
/** @jsx React.DOM */
var React = require('react/addons');
// COMPONENTS
var TextBlock = require('../text_block.jsx');
var PaperHeader = require('../header_paper.jsx')
var SectionHeader = require('../header_section.jsx');
var TableOfContents = require('../table_of_contents.jsx');
var Page = React.createClass({
render: function() {
return (
<div>
<PaperHeader
title={"Page Title"}
authors={["Cole Gleason"]}
/>
<SectionHeader …Run Code Online (Sandbox Code Playgroud) 我有一个Ring的模块签名.IntRing(Z)很容易定义,但我想创建IntRingModP(Z_p).如何在创建模块时将P传递给仿函数来设置它?
module IntRing : Ring = struct
type t = int
let zero = 0
let one = 1
let add a b = a+b
let mult a b = a*b
let compare = compare
let equal a b = (a=b)
let to_string = Int.to_string
let print a = print_string (to_string a)
end;;
module IntRingModP (P : Int) : Ring = struct
let p = P
type t = int
let zero = 0 mod p
let one = 1 …Run Code Online (Sandbox Code Playgroud) 我有一个NodeJS应用程序,它调用一个实现一些OpenCV调用的本机插件.该node-gyp build命令成功,但每次我尝试运行服务器时,node app我得到:
Error: /home/cmaccess/SfMLocalization/VisionLocalizeServer/build/Release/localizeImage.node: undefined symbol: _ZNK2cv9Feature2D5emptyEv
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at bindings (/home/cmaccess/SfMLocalization/VisionLocalizeServer/node_modules/bindings/bindings.js:76:44)
at Object.<anonymous> (/home/cmaccess/SfMLocalization/VisionLocalizeServer/routes/localize.js:28:37)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
Run Code Online (Sandbox Code Playgroud)
在我的生活中,我不能弄清楚为什么会这样.我检查了一个已知的良好版本并重新安装了OpenCV.我甚至没有cv::Feature2D在任何代码中明确使用!有没有人建议可能导致这个未定义的符号错误?
我在使用Django Web服务器测试我的项目时遇到logout()问题.这是我的退出视图:
def logout(request):
logout(request)
return render_to_response('main.html', {})
Run Code Online (Sandbox Code Playgroud)
当我访问/注销(调用此视图)时,我会看到一个弹出窗口,说明Python崩溃了.它没有在控制台中给我任何痕迹.