【问题标题】:beforerender method does not working on jsreport studio in local machinebeforerender 方法在本地机器上的 jsreport studio 上不起作用
【发布时间】:2017-03-17 17:30:36
【问题描述】:

我使用了以下代码,但脚本代码 beforerender 方法在本地机器上不起作用。有人可以告诉我这个方法不起作用。

在 jsreport studio 上使用把手的 html 代码:

<table>
    <tr>
    <th>Country</th>
    <th>Name</th>
    <th>abbrivation</th>
    <th>Area</th>
    <th>Largest_city</th>
    <th>capital</th>
    </tr>
   {{#each stats.RestResponse.result}}
   <tr>
       <td>{{country}}</td>
       <td>{{name}}</td>
       <td>{{abbr}}</td>
       <td>{{area}}</td>
       <td>{{largest_city}}</td>
       <td>{{capital}}</td>
   </tr>
   {{/each}}
</table>


Script code:

function beforeRender(done) { 
    require('request')({  url:"http://services.groupkt.com/state/get/IND/all",   json:true}, function(err, response, body){
        console.log("check-->",JSON.stringify(body));
        request.template.content = JSON.stringify(body);
        request.data = { stats: body };
        done();
    });

}

【问题讨论】:

  • 不确定是否理解...您是否忘记了一些代码或所有内容都存在?你的车把代码在哪里?此外,如果您想使用车把模板,您应该添加带有脚本标签的声明。
  • 这是安装在本地机器上的 jsreport studio。我通过在线为 jsreport studio 运行输出相同的代码,在 jsreport studio 中,脚本 ajax 响应使用把手打印在 html 上,即 {{#each stats.RestResponse.result}} 以 {{/each}} 结尾。那是确切的代码(如果你知道 jsreport studio?)
  • 好吧,我不知道这个工具。在线版本是否使用完全相同的代码或运行也有问题?
  • 谢谢,在网上没有问题,一切正常。在本地机器上设置 jsreport studio 后我遇到了问题。
  • 不客气,很高兴你找到了答案

标签: javascript handlebars.js jsreport


【解决方案1】:

这里我错过了 jsrport studio local 的配置。我在这里找到答案 https://jsreport.net/blog/introducing-jsreport-cli

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-29
    • 2018-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-28
    • 2015-03-02
    相关资源
    最近更新 更多