【发布时间】:2018-07-18 02:19:02
【问题描述】:
我正在使用把手{{each}} 来显示内容。
每个内容都在一个 div-box 中显示其数据,因此多个内容垂直显示,例如:
______
| |
| |
|______|
______
| |
| |
|______|
//.. and so on
相反,我想同时显示一个内容,并能够在按钮的帮助下切换到下一个内容。
右下角有一个按钮,暂时没有任何作用。
______
| |
| |
|___[>]| //click on the button, and the next content will display
HTML/Handlebar 代码:
{{#each family}}
<div class="content-wrapper">
<h1>{{surName}}</h1>
{{#each member}}
<h2>{{firstName}}</h2>
{{/each}}
<button id="btn-next" type="submit">Next</button>
</div>
{{/each}}
有什么好的方法可以实现吗?
【问题讨论】:
-
handlerbar 是无逻辑的:如果您通过设计阻止模板中的逻辑(就像 mustache 那样)将逻辑放在其他地方,那么您的模板最终会整洁。
-
@M.Gara 我明白了,你能告诉我如何“把逻辑放在别处”吗?刚开始学习node.js等。另外,分页(一次显示一页)是一个解决方案还是一个坏主意?
标签: javascript html css node.js handlebars.js