参数列表JS之后的未捕获的SyntaxError:missing)

时间:2016-10-27 09:47:47

标签: javascript html css

我正在应用我的数组结果来查看,但我不知道如何在var中传递多个数组值。我收到了SyntaxError。

var html = '<div class="cr-content"><div class="bank-rates"><ul><li><div class="innr-spl" style="padding: 5px 0;"><span style="display:block;"><img src="+ imageUrl.join"></span><span class="hide">'+ bankName.join("</span></div></li><li><div class=\"innr-spl2\">")+ interestRateMin.join("</div></li><li><div class=\"innr-spl2\">")+ financing.join("</div></li><li class=\"hide\"><div class=\"innr-spl3 kmore\" id=""><i class=\"fa fa-chevron-circle-down\" aria-hidden="true"></i>View Datails</div></li><li><div class="apply-now innr-spl"><a href="http://www.yuho.com/gold-loan/" type="button" role="button" target="_blank" class=\"btn-apply\">Apply Now</a></div></li></ul><div style="clear:both"></div><ul class=\"details\" id="ban_" style = "display:none;"><li><i class=\"fa fa-thumbs-o-up\" aria-hidden="true"></i> Maximum Loan Amount : +maxLoanAmt.join")+'</li><li><i class=\"fa fa-thumbs-o-up\" aria-hidden="true"></i> Max Tenure (In Years) :+repaymentTenureInYears.join'+("</li><li><i class=\"fa fa-thumbs-o-up\" aria-hidden="true"></i> Interest Rate Type : +rateType.join")+'</ul></div></div>' ;  

这是我的html和css标签,我想要应用我的数组结果。

  <div class="cr-content">                
                <div class="bank-rates">
      <ul>
   <li>
   <div class="innr-spl" style="padding: 5px 0;">
          <span style="display:block;"><img src="'.$json["resultList"][$key]["imageUrl"].'"></span>
   <span class="hide">'.$json["resultList"][$key]["bankName"].'</span>
   </div>
   </li>

 <li><div class="innr-spl2">' . $interest . '%' . '</div></li>
 <li><div class="innr-spl2">' . $financing  . '</div></li>
   <li class="hide"><div class="innr-spl3 kmore" id="'.$key.'"><i class="fa fa-chevron-circle-down" aria-hidden="true"></i>View Datails</div> </li>
        <li>
        <div class="apply-now innr-spl"><a href="http://www.yuho.com/gold-loan/" type="button" role="button" target="_blank" class="btn-apply">Apply Now</a></div>
        </li>      
      </ul>
      <div style="clear:both"></div>

      <ul class="details" id="ban_'.$key.'" style = "display:none;">
        <li><i class="fa fa-thumbs-o-up" aria-hidden="true"></i> Maximum Loan Amount : '.$json["resultList"][$key]["maxLoanAmt"].'</li>
        <li><i class="fa fa-thumbs-o-up" aria-hidden="true"></i> Max Tenure (In Years) : '.$json["resultList"][$key]["repaymentTenureInYears"].'</li>
        <li><i class="fa fa-thumbs-o-up" aria-hidden="true"></i> Interest Rate Type : '.$json["resultList"][$key]["rateType"].'</li>    
      </ul>

    </div>
    </div>

我的阵列

var rateType = [];
data.forEach(function(element){
   this.push(element.rateType);
}, rateType );

var interestRateMin = [];
data.forEach(function(element){
   this.push(element.interestRateMin);
}, interestRateMin );

var financingPercentageMax = [];
data.forEach(function(element){
   this.push(element.financingPercentageMax);
}, financingPercentageMax );

var interestRateMax = [];
data.forEach(function(element){
   this.push(element.interestRateMax);
}, interestRateMax );

var financingPercentageMin = [];
data.forEach(function(element){
   this.push(element.financingPercentageMin);
}, financingPercentageMin );

var repaymentTenureInYears = [];
data.forEach(function(element){
   this.push(element.repaymentTenureInYears);
}, repaymentTenureInYears );

var maxLoanAmt = [];
data.forEach(function(element){
   this.push(element.maxLoanAmt);
}, maxLoanAmt );

1 个答案:

答案 0 :(得分:3)

问题是你没有逃脱"

var html = '<div class="cr-content"><div class="bank-rates"><ul><li><div class="innr-spl" style="padding: 5px 0;"><span style="display:block;"><img src="+ imageUrl.join"></span><span class="hide">'+ bankName.join("</span></div></li><li><div class=\"innr-spl2\">")+ interestRateMin.join("</div></li></ul></div></div>");   
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^----------^

固定代码

var html = '<div class="cr-content"><div class="bank-rates"><ul><li><div class="innr-spl" style="padding: 5px 0;"><span style="display:block;"><img src="' + imageUrl.join() + '"></span><span class="hide">' + bankName.join("</span></div></li><li><div class=\"innr-spl2\">") + interestRateMin.join("</div></li><li><div class=\"innr-spl2\">") + financing.join("</div></li><li class=\"hide\"><div class=\"innr-spl3 kmore\" id=\"\"><i class=\"fa fa-chevron-circle-down\" aria-hidden=\"true\"></i>View Datails</div></li><li><div class=\"apply-now innr-spl\"><a href=\"http://www.apnapaisa.com/gold-loan/\" type=\"button\" role=\"button\" target=\"_blank\" class=\"btn-apply\">Apply Now</a></div></li></ul><div style=\"clear:both\"></div><ul class=\"details\" id=\"ban_\" style = \"display:none;\"><li><i class=\"fa fa-thumbs-o-up\" aria-hidden=\"true\"></i> Maximum Loan Amount : " + maxLoanAmt.join("") + '</li><li><i class=\"fa fa-thumbs-o-up\" aria-hidden="true"></i> Max Tenure (In Years) :+repaymentTenureInYears.join' + ("</li><li><i class=\"fa fa-thumbs-o-up\" aria-hidden=\"true\"></i> Interest Rate Type : " + rateType.join("") + '</ul></div></div>';