简体   繁体   English

在 Rails 6 jquery 中加载主题资产和资产加载顺序

[英]Loading theme assets in rails 6 jquery and assets load order

I have a rails app with the logic almost done and I'm now loading a theme from ThemeForest, I've loaded in the stylesheets, however, javascript wise I'm having issues.我有一个逻辑几乎完成的 Rails 应用程序,现在我正在从 ThemeForest 加载一个主题,我已经加载了样式表,但是,javascript 明智我遇到了问题。 I've installed jquery via Yarn.我已经通过 Yarn 安装了 jquery。

Here are the console errors这是控制台错误

在此处输入图像描述

Here is my application.js file这是我的application.js文件

在此处输入图像描述

As you can see it's linking the main.js file which is just a list of the themes javascript files as shown in the theme files如您所见,它正在链接 main.js 文件,该文件只是主题 javascript 文件的列表,如主题文件中所示

在此处输入图像描述

I'm not sure where I'm going wrong.我不确定我哪里出错了。

Create in app/assets/javascripts/main.js在 app/assets/javascripts/main.js 中创建

In main.js file import your assets.. for example:在 main.js 文件中导入您的资产.. 例如:

//= require jquery/dist/jquery
//= require fastclick/lib/fastclick

in your template在您的模板中

<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'main', 'data-turbolinks-track': 'reload' %>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM