Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Can';t使用wkhtmltopdf返回承诺后运行回调函数_Javascript_Google Visualization_Javascript Objects_Es6 Promise_Wkhtmltopdf - Fatal编程技术网

Javascript Can';t使用wkhtmltopdf返回承诺后运行回调函数

Javascript Can';t使用wkhtmltopdf返回承诺后运行回调函数,javascript,google-visualization,javascript-objects,es6-promise,wkhtmltopdf,Javascript,Google Visualization,Javascript Objects,Es6 Promise,Wkhtmltopdf,我正在使用googlecharts创建折线图。然后将生成的html传递到windows中的wkhtmltopdf版本0.12.5(带补丁qt),这是一个用于将html页面转换为PDF的shell实用程序 wkhtmltopdf使用旧版本的webkit(浏览器引擎)来执行javascript代码,因此除了不支持其他ES6功能外,它还将Promise视为普通的对象 现在是问题 JS代码[main.JS]: 1. google.load("visualization", "1", { packages

我正在使用
googlecharts
创建折线图。然后将生成的html传递到windows中的
wkhtmltopdf
版本0.12.5(带补丁qt),这是一个用于将html页面转换为PDF的shell实用程序

wkhtmltopdf使用旧版本的
webkit
(浏览器引擎)来执行javascript代码,因此除了不支持其他ES6功能外,它还将
Promise
视为普通的
对象

现在是问题

JS代码[main.JS]:

1. google.load("visualization", "1", { packages: ["corechart"] });

2. google.setOnLoadCallback(function () {
3.  drawChart();
4. });

5. function drawChart() {
6. var data = google.visualization.arrayToDataTable(
7.  [
8.  // some data
9.  ]
10.  );
11. var options = {
12    // some options
13. };

14. var chart = new google.visualization.LineChart(
15.    document.getElementById("node_chart_div1") // a div element in html
16.  );

17.  chart.draw(data, options);
18. }
 <!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Line Chart</title>
    <script
      src="https://code.jquery.com/jquery-3.5.0.js"
      integrity="sha256-r/AaFHrszJtwpe+tHyNi/XCfMxYpbsRg2Uqn0x3s2zc="
      crossorigin="anonymous"
    ></script>
    <script
      type="text/javascript"
      src="https://www.gstatic.com/charts/loader.js"
    ></script>
  </head>
  <body>
    <div id="test"></div>
    <div id="node_chart_div1" class="cellchart"></div>
  </body>
  <script src="main.js"></script>
</html>
HTML代码:

1. google.load("visualization", "1", { packages: ["corechart"] });

2. google.setOnLoadCallback(function () {
3.  drawChart();
4. });

5. function drawChart() {
6. var data = google.visualization.arrayToDataTable(
7.  [
8.  // some data
9.  ]
10.  );
11. var options = {
12    // some options
13. };

14. var chart = new google.visualization.LineChart(
15.    document.getElementById("node_chart_div1") // a div element in html
16.  );

17.  chart.draw(data, options);
18. }
 <!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Line Chart</title>
    <script
      src="https://code.jquery.com/jquery-3.5.0.js"
      integrity="sha256-r/AaFHrszJtwpe+tHyNi/XCfMxYpbsRg2Uqn0x3s2zc="
      crossorigin="anonymous"
    ></script>
    <script
      type="text/javascript"
      src="https://www.gstatic.com/charts/loader.js"
    ></script>
  </head>
  <body>
    <div id="test"></div>
    <div id="node_chart_div1" class="cellchart"></div>
  </body>
  <script src="main.js"></script>
</html>
在链接上找到上述代码的实时演示

非常感谢您的任何帮助/建议