我通过NPM安装了particles.js。当我尝试将其加载到app.js文件中时,出现了错误,如“ Uncaught SyntaxError:JSON输入意外结束 在JSON.parse() 在XMLHttpRequest.xhr.onreadystatechange”
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title></title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div class="container">
<div id="particles-js"></div>
</div>
<script src="node_modules/particles.js/particles.js"></script>
<script src="js/app.js"></script>
</body>
</html>
// Load Particle JS
particlesJS.load('particles-js', 'js/particle.json', function() {
console.log('callback - particles.js config loaded');
});