【发布时间】:2016-10-24 12:59:13
【问题描述】:
我必须使用 Meteor 创建一个协作应用程序,但我一直在创建 UI。 我想为不同的页面设置一些按钮,但我想使用模板来执行此操作,这样我就不必加载另一个页面。 问题是我无法通过单击按钮来更改模板。 有没有人有一个小代码 sn-p 我可以用来解决我的问题?
提前致谢!!
【问题讨论】:
标签: javascript user-interface templates meteor
我必须使用 Meteor 创建一个协作应用程序,但我一直在创建 UI。 我想为不同的页面设置一些按钮,但我想使用模板来执行此操作,这样我就不必加载另一个页面。 问题是我无法通过单击按钮来更改模板。 有没有人有一个小代码 sn-p 我可以用来解决我的问题?
提前致谢!!
【问题讨论】:
标签: javascript user-interface templates meteor
使按钮点击this.setState({templateName: template})。
然后在你的渲染中:
if (this.setState.templateName == 'template1'){
<Template1 />
}else if (this.setState.templateName == 'template2'){
<Template2 />
}else etc
您还可以在此处查看我制作的完整演示:https://github.com/Frazer/meteor-react-nav/tree/master/lib/jsx - 它以比我刚刚在此处提供的代码 sn-p 更复杂的方式呈现。
【讨论】: