meteor flowrouter中如何在模板之间传递参数数据
我有一个名为:Orders的模板,它显示我的订单图像集合:meteor flowrouter中如何在模板之间传递参数数据,meteor,flowlayout,Meteor,Flowlayout,我有一个名为:Orders的模板,它显示我的订单图像集合: {{#each images}} <div class="images"> <a href="/order/{{this._id}}"> <img class="image" src="{{this.url }}" /></a> </div> {{/each}} 和orders.html: <a href="/order/{{this._id}}"> &l
{{#each images}}
<div class="images">
<a href="/order/{{this._id}}"> <img class="image" src="{{this.url }}" /></a>
</div>
{{/each}}
和orders.html:
<a href="/order/{{this._id}}"> <img class="image" src="{{this.url }}" /></a>
我使用了一个动态布局模板来显示订单,显示的很好。
如何设置单订单html、路由和渲染???来回答您的问题: 从路由开始,应按如下方式在路径中传递id参数:
FlowRouter.route('/order/:imageId', {
action: function() {
FlowLayout.render("layout",{ top: "order", main: "test" });
}
});
查看order.html文件上的呈现,该文件包含模板顺序,类似于:
<template name="order">
{{#with image}}
<!-- whatever you want to do -->
<img src="{{url}}" />
{{/with}}
</template>
最后,在服务器端,您应该发布:
Meteor.publish('oneImage', function(imageId) {
return Images.findOne({ _id: imageId });
}
通过这种方式,您不再需要您的事件单击.image
,您就优化了性能!)
顺便说一句,在你的
{{{{each}}
循环中的orders.html上,你不需要写{{this.url}
或者{this.{id}}
,{url}
和{id}
都很好;) 要回答您的问题:
从路由开始,应按如下方式在路径中传递id参数:
FlowRouter.route('/order/:imageId', {
action: function() {
FlowLayout.render("layout",{ top: "order", main: "test" });
}
});
查看order.html文件上的呈现,该文件包含模板顺序,类似于:
<template name="order">
{{#with image}}
<!-- whatever you want to do -->
<img src="{{url}}" />
{{/with}}
</template>
最后,在服务器端,您应该发布:
Meteor.publish('oneImage', function(imageId) {
return Images.findOne({ _id: imageId });
}
通过这种方式,您不再需要您的事件单击.image
,您就优化了性能!)
顺便说一句,在你的
{{{{each}}
循环中的orders.html上,你不需要写{{this.url}
或者{this.{id}}
,{url}
和{id}
都很好;) 要检索请求参数,可以使用:
FlowRouter.current().route._params.keys.id
要检索请求参数,可以使用:
FlowRouter.current().route._params.keys.id
谢谢泽维尔,我会试试这个。谢谢泽维尔,我会试试这个。