0

收到此错误:

在这一行:totalFundedLabel.push( "label": "Funded");

JS:

var totalFunded =  '${totalFunded}';
var totalUnfunded =  '${totalUnfunded}';

var totalFundedValue = [];
var totalFundedLabel = [];
var totalFundedText = [];

var unFundedValue = [];
var unFundedLabel = [];
var unFundedText = [];

if (totalFunded != null)  
{
totalFundedLabel.push( "label": "Funded");
totalFundedValue.push( "value": <tld-msst:fc-value var="${totalFunded}"/>);
totalFundedText.push( "toolText": "<fmt:formatNumber value='${totalFunded}' type='currency' groupingUsed='true' />");
}


if (totalUnfunded != null)  
{
unFundedLabel.push( "label": "unFunded");
unFundedValue.push( "value": <tld-msst:fc-value var="${totalUnfunded}"/>);
unFundedText.push( "toolText": "<fmt:formatNumber value='${totalUnfunded}' type='currency' groupingUsed='true' />");
 }

渲染的 HTML:

var totalFunded =  '109321734.06';
var totalUnfunded =  '381234572.79';

var totalFundedValue = [];
var totalFundedLabel = [];
var totalFundedText = [];

var unFundedValue = [];
var unFundedLabel = [];
var unFundedText = [];

if (totalFunded != null)  
{
totalFundedLabel.push( "label": "Funded");
totalFundedValue.push( "value": "109321734.06");
totalFundedText.push( "toolText": "$109,321,734.06");
}


if (totalUnfunded != null)  
{
unFundedLabel.push( "label": "unFunded");
unFundedValue.push( "value": "381234572.79");
unFundedText.push( "toolText": "$381,234,572.79");
}
4

2 回答 2

8

这是一个语法错误,因为它确实如此。你可能想要:

unFundedLabel.push({ label: "unFunded"});

花括号创建了一个对象,该对象具有称为“标签”的属性。如果属性名称看起来像标识符(通常),则不需要在属性名称上加上引号。看起来你所有的.push()电话都以同样的方式中断。

于 2013-01-22T14:10:36.740 回答
0

您在所有推送语句中都缺少大括号{&}

if (totalFunded != null)  
{
totalFundedLabel.push( {"label": "Funded"});
totalFundedValue.push( {"value": <tld-msst:fc-value var="${totalFunded}"/>});
totalFundedText.push( {"toolText": "<fmt:formatNumber value='${totalFunded}' type='currency' groupingUsed='true' />"});
}


if (totalUnfunded != null)  
{
unFundedLabel.push( {"label": "unFunded"});
unFundedValue.push( {"value": <tld-msst:fc-value var="${totalUnfunded}"/>});
unFundedText.push( {"toolText": "<fmt:formatNumber value='${totalUnfunded}' type='currency' groupingUsed='true' />"});
 }
于 2013-01-22T14:14:05.213 回答