【问题标题】:docsify: out of multiple scripts only one script works on a single pagedocsify:在多个脚本中,只有一个脚本适用于单个页面
【发布时间】:2020-05-17 23:47:15
【问题描述】:

我对 javascript 和 docsify 非常陌生。我有以下脚本可以在简单的 html 页面上正常工作,但是当我使用 docsify 将它们生成为页面时,只有一个脚本显示了图表。这适用于我使用 vegaEmbed 使用多个图表生成的一堆不同页面。

<div id="script_1"></div>
<script type="text/javascript">
  var spec = "https://raw.githubusercontent.com/gunrock/io/master/plots/gunrock_primitives_tc_avg_process_time.json";
  vegaEmbed('#script_1', spec).then(function(result) {
    // Access the Vega view instance (https://vega.github.io/vega/docs/api/view/) as result.view
  }).catch(console.error);
</script>

<div id="script_2"></div>
<script type="text/javascript">
  var spec = "https://raw.githubusercontent.com/gunrock/io/master/plots/gunrock_primitives_tc_edges.json";
  vegaEmbed('#script_2', spec).then(function(result) {
    // Access the Vega view instance (https://vega.github.io/vega/docs/api/view/) as result.view
  }).catch(console.error);
</script>

您可以在此处找到该页面:https://gunrock.github.io/docs/#/analysis/results_tc

我包括以下内容:

<!-- Vega and Vega-Lite Includes -->
<script src="https://cdn.jsdelivr.net/npm/vega@5"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite@4"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script>

【问题讨论】:

    标签: docsify


    【解决方案1】:

    根据文档,仅执行第一个脚本标记:https://docsify.js.org/#/configuration?id=executescript

    【讨论】:

      猜你喜欢
      • 2015-01-28
      • 2013-06-01
      • 1970-01-01
      • 2021-07-07
      • 2017-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多