我正在尝试学习流星反应,我有一个关于使用 FlowRouter 将内容插入 HTML 模板页面的问题。
假设一切都正确导入,这是相关代码:
路线.jsx
FlowRouter.route('/post/:postId', {
name: 'posts.single',
action({postId}) {
mount(MainLayoutCtx, {
content: () => (<Post postId={postId}/>)
});
}
});
index.jsx - MainLayoutCtx 指向的位置
const Layout = ({content = () => null }) => (
//code here
);
在 index.jsx 中,{content = () => null}。这不是说 content 是一个没有参数并且输出 null 的对象字面量吗?
但是当在 routes.jsx 中传递内容时,它是() => (/Post postId={postId}/>)那么输出 Post 的内容不是将 postId 作为 prop 传入吗?
这与 index.jsx 的预期有何匹配?