2017-03-13 3 views
0

次のコードを使用しましたが、スクリプトコードbeforerenderメソッドはローカルマシンでは動作しません。いくつかの場合、このメソッドは動作しません。 jsreportスタジオにハンドルを使用してbeforerenderメソッドがローカルマシンのjsreportスタジオで動作しません

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(); 
    }); 

} 
+0

あなたはいくつかのコードを忘れましたか、それともすべてが存在しますか?あなたのハンドルバーコードはどこですか?また、ハンドルバーテンプレートを使用する場合は、宣言にscriptタグを追加する必要があります。 –

+0

ローカルマシンにインストールされているjsreportスタジオです。 jsreportスタジオでは、スクリプトのajaxレスポンスは、{{/ each}}で終わるハンドルバー{{#each stats.RestResponse.result}}を使用してHTMLに出力されます。それは正確なコードです(もしあなたがjsreport studioを知っていれば?) – saranilango

+0

私はこのツールを知らなかった。オンライン版はまったく同じコードで動作しているのですか、それとも実行する問題がありますか? –

答えて

関連する問題