【问题标题】:Uncaught TypeError: pJS_tag is null - ParticlesJS fails out of the boxUncaught TypeError: pJS_tag is null - ParticlesJS 开箱即用失败
【发布时间】:2021-02-13 00:08:07
【问题描述】:

我正在尝试不加修改地运行 Particles.Js,但它开箱即用失败并出现此错误:

Uncaught TypeError: pJS_tag is null

我已经通过 npm install 安装了它。这是我的 HTML

particlesJS.load('particles-js', 'assets/particles.json', function() {
  console.log('callback - particles.js config loaded');
});
<!doctype html>
<html>
    <head>
      <link rel="stylesheet" href="./style.css">
        <script src="/node_modules/particles.js/particles.js"> </script> 

    </head>

    <body>
        <div class="particles-js"></div>
        <div class="banner">test</div>
    <script src= 
        "/node_modules/particles.js/demo/js/app.js"> 
    </script>
    </body>
</html>

【问题讨论】:

  • 我认为您需要将 particles.js 包含在 &lt;script src="/node_modules/particles.js/demo/js/app.js"&gt;&lt;/script&gt; 之前。

标签: javascript html particles.js


【解决方案1】:

我发现我的错误,我忘记设置“id”字段,并假设“class”足够好。

示例: 改变

<div class="particles-js"></div>

到:

<div class="particles-js" id="particles-js"></div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-24
    • 2021-07-04
    • 2021-07-15
    • 2021-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-04
    相关资源
    最近更新 更多