I wrote the next row in index.html.erb
:
<script src="/app/assets/javascripts/jquery.js"></script>
I added the file: jquery.js
to the folder: app/assets/javascripts
but in the console, I got an error:
GET http://localhost:3000/app/assets/javascripts/jquery.js 404 (Not Found)
please help.
<script src="assets/jquery.js" type="text/javascript"></script>
The problem is from where are you calling the jquery.js
file. I mean, it depends of where do you have your index.html
file.
For example, if your index.html is on /app/index.html
, try:
<script src="assets/javascripts/jquery.js"></script>
你不需要完整的路径,只需assets/jquery.js
就足够了:
<script src="assets/jquery.js"></script>
你能否在这上面使用铁轨助手?
<%= javascript_include_tag "jquery" %>
I think that the most common place to define javascript files to add is the manifest file
: app/assets/javasripts/application.js
. It looks like this :
//= require jquery
//= require jquery-ui
//= require jquery_ujs
Then you have your assets added application-wide .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.