Rails 5不会在供应商/资产/javascript目录中加载js文件

时间:2022-08-02 20:42:18

I add some third-party JS libraries to the vendor/assets/javascripts/tooltipster.js. After that, I add in the application.js:

我将一些第三方JS库添加到供应商/资产/javascript /tooltipster.js中。之后我加入application。js:

//= require tooltipster

, but I get this error:

但是我得到了这个错误:

couldn't find file 'tooltipster' with type 'application/javascript'

无法找到'application/javascript'文件'tooltipster'

Checked in these paths:

在这些路径检查:

  /home/masterbyter/Desktop/theaterway/app/assets/config
  /home/masterbyter/Desktop/theaterway/app/assets/images
  /home/masterbyter/Desktop/theaterway/app/assets/javascripts
  /home/masterbyter/Desktop/theaterway/app/assets/stylesheets
  /var/lib/gems/2.3.0/gems/font-awesome-rails-4.7.0.2/app/assets/fonts
  /var/lib/gems/2.3.0/gems/font-awesome-rails-4.7.0.2/app/assets/stylesheets
  /var/lib/gems/2.3.0/gems/coffee-rails-4.2.2/lib/assets/javascripts
  /var/lib/gems/2.3.0/gems/jquery-rails-4.3.1/vendor/assets/javascripts
  /var/lib/gems/2.3.0/gems/actioncable-5.1.2/lib/assets/compiled
  /var/lib/gems/2.3.0/gems/actionview-5.1.2/lib/assets/compiled

How to add third-party JS libraries in Rails 5 ?

如何在Rails 5中添加第三方JS库?

2 个解决方案

#1


6  

Just include

只包括

//= require tooltipster.js

in application.js and you will need to restart your Rails server.

在应用程序中。需要重新启动Rails服务器。

#2


0  

Follow commands:

遵循命令:

Gemfile

gem 'tooltipster-rails'

Then run

然后运行

bundle

application.js

//= require tooltipster.main

application.css

*= require tooltipster.main

#1


6  

Just include

只包括

//= require tooltipster.js

in application.js and you will need to restart your Rails server.

在应用程序中。需要重新启动Rails服务器。

#2


0  

Follow commands:

遵循命令:

Gemfile

gem 'tooltipster-rails'

Then run

然后运行

bundle

application.js

//= require tooltipster.main

application.css

*= require tooltipster.main