我正在尝试在我的 ruby on rails 项目上实现粒子效果,但是在遵循了一些教程和可用的粒子包的 github 指令之后,即使我指定了灰色背景,我也没有在我的本地服务器上获得效果。也许您可以建议哪一个是我的错误或我缺少什么。这是我的代码。
应用程序.js
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require particles.js
//= require app.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
应用程序.css
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/
返回.css
#particles-js{
backgorund: #444;
}
主页.html.erb
<h1>Rubsol#home</h1>
<p>Find me in app/views/rubsol/home.html.erb</p>
<div id="particles-js"></div>
我没有放线
<script src="particles.js"></script>
<script src="particles.js"></script>
因为我认为它们不是必需的,因为我使用的是 //= require_tree 但我也尝试过放置它们并且它没有显示任何内容。
back.css 只是为了设置粒子效果背景的颜色而创建的,我没有发布particle.js 和 app.js 的内容,因为我没有更改这些文件中的任何内容,它们是相同的你可以从github下载。
https://github.com/VincentGarreau/particles.js/
这是我得到的: