我试图让GitGraph工作并为要放在一起的文档生成类似GitFlow的图形。

这是我的HTML文件:

<html>
  <head>
    <title>GitFlow</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gitgraph.js/1.11.4/gitgraph.min.css"></script>
    <script>
      var gitgraph = new GitGraph({
        template: "blackarrow",
        reverseArrow: false,
        orientation: "horizontal",
        mode: "compact"
      });
    </script>
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/gitgraph.js/1.11.4/gitgraph.css" />
  </head>
  <body>
    <canvas id="gitGraph"></canvas>
  </body>
</html>


当我在浏览器中打开它时,我只会得到一个空白页面。在Chrome开发者控制台中,我看到以下错误:

Uncaught ReferenceError: GitGraph is not defined
at gitgraph.html:6


因此由于某种原因,它没有从CDN中引入GitGraph。有人可以发现我要去哪里吗?

最佳答案

得到了它的工作:

<html>
  <head>
    <title>GitFlow</title>
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/gitgraph.js/1.11.4/gitgraph.css" />
  </head>
  <body>
    <canvas id="gitGraph"></canvas>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gitgraph.js/1.11.4/gitgraph.min.js"></script>
    <script>
      var gitgraph = new GitGraph({
        template: "blackarrow",
        reverseArrow: false,
        orientation: "horizontal",
        mode: "compact"
      });

      gitgraph.branch().commit().commit();
    </script>
  </body>
</html>

关于javascript - GitGraph JS未从CDN加载,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48106879/

10-11 14:53