这很难解释。我需要在 Coreldraw 中填写一些我喜欢的内容并保存为 SVG
.当 Coreldraw 保存我的 svg 时,我得到了一个名为 soil_Images
的文件夹。与 soil_ImgID1.png
内部和soil.svg
.我把web-app/images
放在里面项目。出于某种原因,图像 png 未显示。
我的 gsp 中有我的 svg:
<image x="177" y="76" width="36" height="23" preserveAspectRatio="none" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/projectName/images/soil.svg"></image>
还有我的
soil.svg
有另一个图像标签,显示我想要的真实图像: <image x="44" y="29" width="8156" height="11707" xlink:href="soil_Images/soil_ImgID1.png"/>
我试图添加一个上下文路径,如:
${application.contextPath}/images/soil_Images/soil_ImgID1.png
.那没有用。我错过了什么?
最佳答案
建筑关闭 Matt Busche's blog post在将 Assets 管道与 SVG 和 PNG 后备图像一起使用时,请尝试指向 Assets 管道位置而不是硬编码。请注意 assetPath
与 src
(如果不是默认 Assets 管道图像位置,则为您使用的相对路径)和图像名称。
<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="${assetPath(src: 'imgs/' + logoSVG)}" src="${assetPath(src: 'imgs/' + logoPNG)}"></image>
关于引用 png 的 Grails svg 图像 href 未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30468611/