问题
I was trying to include my slider.js file to spree application but it is not working. I have looked and found that we must include it manually in all.js file but its not working.
I include in my all.js file:
//= require store/spree_core
//= require store/spree_auth
//= require store/spree_api
//= require store/spree_promo
//= require store/slider.js
But i am not sure if the slider.js file is included in all.js file. Is there any method to test it.
回答1:
By default spree app inlcudes all css files in spreesite/app/assets/stylesheets/store/all.css
by *= require_tree .
And js files spreesite/app/assets/javascripts/store/all.js the same *= require_tree .
If you need to add stylesheet or js just put the file in spreesite/app/assets/stylesheets/store folder.
Spree automatically includes them.
If js file still doesn't work try rake assets:precompile
回答2:
There's a decent chance you precompiled your assets. Try clearing them out, using the following:
bundle exec rake assets:clean
来源:https://stackoverflow.com/questions/9662116/including-js-file-in-spree-application