rails
rails中使用图片有特定的书写格式,注意括号单位位置,下边两种方法都可以正常使用
<a href='#' class='eth_connect' ><%= image_pack_tag('metamask.png', style: 'width: 24px; height: 24px') %>MetaMask</a>
<%= image_pack_tag 'application.png', size: '16x10', alt: 'Edit Entry' %>
同时,项目需要使用的图片必须放在特定的文件夹:app/JavaScript/zaiimages/
此时,图片仍然不能显示,在packs/application.js
文件增加下面的内容
const importAll = (r) => r.keys().map(r)importAll(require.context('../images', false, /\.(png|jpe?g|svg)$/));
刷新页面,图片就可以显示了
发布者:admin,转转请注明出处:http://www.yc00.com/news/1689026903a197115.html
评论列表(0条)