【发布时间】:2016-02-05 04:52:05
【问题描述】:
因此,我正在为 mdl 构建定价表,并尝试使用模板填充不同的计划选项,但在显示计划的功能部分时遇到问题。它看起来像:
这是我想要的代码笔:http://codepen.io/sylverfyst/pen/QyVYmK
谁能告诉我我的 Javascript 中的 blaze PlansRowOne 和 PlansRowTwo 对象哪里出了问题?我认为它可能是嵌套功能:[],但我不知道它的实际语法是什么。
这是我迄今为止尝试过的:
外部 HTML
<template name="sell">
<div>
<div class="mdl-grid">
<div class="mdl-cell mdl-cell--12-col"><h1>CHOOSE A PLAN TO JOIN TODAY</h1></div>
<div class="mdl-cell mdl-cell--3-col"></div><!-- Spacer -->
{{#each PlansRowOne}}
{{> pricingItem}}
{{/each}}
<div class="mdl-cell mdl-cell--3-col"></div><!-- Spacer -->
{{#each PlansRowTwo}}
{{> pricingItem}}
{{/each}}
<div class="mdl-cell mdl-cell--3-col"></div><!-- Spacer -->
</div>
</div>
</template>
Javascript 文件
Template.sell.helpers({
PlansRowOne: [
{title: "Basic 6 Month", Dollars: "$44.", Cents: "95", term: "/6 Months", Features: [{feature: "1 Listing for your Business"}, {feature: "Searchable Listing"}, {feature: "Ads on Listing"}, {feature: "Upload Photos"}, {feature: "Unlimited Categories"}, {feature: "X"}]},
{title: "Basic 3 Month", Dollars: "$64.", Cents: "95", term: "/3 Months", Features: [{feature: "1 Listing for your Business"}, {feature: "Searchable Listing"}, {feature: "Ads on Listing"}, {feature: "Upload Photos"}, {feature: "Unlimited Categories"}, {feature: "X"}]},
{title: "Showcase 6 Month", Dollars: "$64.", Cents: "95", term: "/6 Months", Features: [{feature: "1 Listing for your Business"}, {feature: "Searchable Listing"}, {feature: "Ads on Listing"}, {feature: "Upload Photos"}, {feature: "Unlimited Categories"}, {feature: "1st in Search Listings"}]},
],
PlansRowTwo: [
{title: "Professional Silver", Dollars: "$74.", Cents: "95", term: "/Month", Features: [{feature: "One Time Set Up Fee of $29.95"}, {feature: "10 Searchable Listings"}, {feature: "Ads on Listings"}, {feature: "Upload Photos"}, {feature: "Unlimited Categories"}, {feature: "X"}]},
{title: "Professional Gold", Dollars: "$94.", Cents: "95", term: "/Month", Features: [{feature: "One Time Set Up Fee of $29.95"}, {feature: "10 Searchable Listings"}, {feature: "No Ads on Showcase Listings"}, {feature: "Upload Photos"}, {feature: "Unlimited Categories"}, {feature: "2 Showcase Listings"}]},
{title: "Professional Platinum", Dollars: "$114.", Cents: "95", term: "/Month", Features: [{feature: "One Time Set Up Fee of $29.95"}, {feature: "10 Searchable Listings"}, {feature: "No Ads on Showcase Listings"}, {feature: "Upload Photos"}, {feature: "Unlimited Categories"}, {feature: "5 Showcase Listings"}]},
]
});
内部 HTML
<template name="pricingItem">
<div class="pricing-item mdl-cell mdl-cell--2-col mdl-shadow--2dp">
<div class="pricing-title">
{{title}}
</div>
<div class="pricing-value">{{Dollars}}<span class="smallText">{{Cents}}</span>
<span class="undertext">{{term}}</span>
</div>
<ul class="mdl-list list">
{{#each features}}
<li class="mdl-list__item">{{feature}}</li>
{{/each}}
</ul>
<div class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent mdl-button--raised button">Subscribe</div>
</div>
</template>
【问题讨论】:
标签: javascript meteor meteor-blaze