gpt4 book ai didi

javascript 未在 Rails 6 中编译

转载 作者:行者123 更新时间:2023-11-28 16:48:35 25 4
gpt4 key购买 nike

我最近更新到 Rails 6.0.2 一切正常,但当我创建一个新项目时,我发现 javascript 文件夹已从 asset pipeline 移至 app 文件夹。我使用主题创建一个简单的单页网站,除了 javascript 之外,一切正常。我已经放置了所有 javascript 文件 app/javascripts/packs,以下是我在主页上调用它的方式。

<script type="text/javascript" src="/javascript/jquery.min.js"></script>
<script type="text/javascript" src="/javascript/jquery-migrate.min.js"></script>
<script type="text/javascript" src="/javascript/bootstrap.min.js"></script>
<script type="text/javascript" src="/javascript/jquery.themepunch.tools.min.js"></script>
<script type="text/javascript" src="/javascript/jquery.themepunch.revolution.min.js"></script>
<script type="text/javascript" src="/javascript/snap.min.js"></script>
<script type="text/javascript" src="/javascript/owl.carousel.min.js"></script>
<script type="text/javascript" src="/javascript/jquery.prettyPhoto.js"></script>
<script type="text/javascript" src="/javascript/jquery.prettyPhoto.init.min.js"></script>
<script type="text/javascript" src="/javascript/jQuery.headroom.min.js"></script>
<script type="text/javascript" src="/javascript/headroom.min.js"></script>
<script type="text/javascript" src="/javascript/script.js"></script>

<script type="text/javascript" src="/javascript/revolution.extension.video.min.js"></script>
<script type="text/javascript" src="/javascript/revolution.extension.slideanims.min.js"></script>
<script type="text/javascript" src="/javascript/revolution.extension.actions.min.js"></script>
<script type="text/javascript" src="/javascript/revolution.extension.layeranimation.min.js"></script>
<script type="text/javascript" src="/javascript/revolution.extension.kenburn.min.js"></script>
<script type="text/javascript" src="/javascript/revolution.extension.navigation.min.js"></script>
<script type="text/javascript" src="/javascript/revolution.extension.migration.min.js"></script>
<script type="text/javascript" src="/javascript/revolution.extension.parallax.min.js"></script>

这是我的 application.js

console.log('Hello World from Webpacker')
require("packs/bootstrap")
require("packs/headroom")
require("packs/jquery-migrate")
require("packs/jQuery.headroom")
require("packs/jquery")
require("packs/jquery.prettyPhoto.init")
require("packs/jquery.prettyPhoto")
require("packs/jquery.themepunch.revolution")
require("packs/jquery.themepunch.tools")
require("packs/owl.carousel")
require("packs/revolution.extension.actions")
require("packs/revolution.extension.kenburn")
require("packs/revolution.extension.layeranimation")
require("packs/revolution.extension.migration")
require("packs/revolution.extension.navigation")
require("packs/revolution.extension.parallax")
require("packs/revolution.extension.slideanims")
require("packs/revolution.extension.video")

但我还是明白

ActionController::RoutingError (No route matches [GET] "/javascript/revolution.extension.parallax.min.js"):

最佳答案

如果你已经在 application.js 中加载了所有的js。难道调用就足够了吗

 <%= yield :javascript %> 

在application.html.erb中。另一种方法是将 js 文件放在 public/js/packs 目录中并访问这些文件,例如

<script src="/js/packs/jquery.prettyPhoto.init"></script>

关于javascript 未在 Rails 6 中编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60247789/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com