gpt4 book ai didi

javascript - 预编译 application.js 资源

转载 作者:行者123 更新时间:2023-11-28 08:27:11 26 4
gpt4 key购买 nike

如何让我的 application.js 中的代码正常工作,以便我可以预编译此处使用的图像?我应该使用什么 Rails 助手?

    $(document).ready(function(){
$(".imgthumb").click(function(){
$(".thumbnailcurrent").addClass("thumbnails");
$(".thumbnails").removeClass("thumbnailcurrent");
$(this).addClass("thumbnailcurrent");
$(this).removeClass("thumbnails");

var img=($(this).attr("data-id"));

if (img==1) {

$('.imgbig').html("<%= asset_path src: 'flappy1.jpg', height: '275', width: '391' %>");
} else if (img==2) {

$('.imgbig').html("<%= asset_path src: 'flappy2.jpg', height: '275', width: '391' %>");
} else if (img==3) {

$('.imgbig').html("<%= asset_path src: 'flappy3.jpg', height: '275', width: '391' %>");
}


});

});

最佳答案

预编译的图像位于公共(public)/ Assets 路径中?为什么不直接使用这个路径呢?

关于javascript - 预编译 application.js 资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22264137/

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