问题描述
我正在尝试不加修改地运行 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>
解决方法
我发现我的错误,我忘记设置“id”字段,并认为“class”已经足够了。
示例: 改变
<div class="particles-js"></div>
到:
<div class="particles-js" id="particles-js"></div>