首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SVG对象显示SVG代码而不是SVG图形?

SVG对象显示SVG代码而不是SVG图形?
EN

Stack Overflow用户
提问于 2013-02-25 03:48:15
回答 1查看 200关注 0票数 2

在我的网站上,我有一个用于显示矢量图像的SVG对象,在离线测试时,一切正常,但当我将其上传到我的网站上时,该对象显示了有问题的SVG的代码。可在此处查看:link to site with svg

对象代码:

代码语言:javascript
复制
<object type="image/svg+xml" data="ppvisual.svg" width="702px" height="259.37px">
<param name="colour" value="<?php echo $colour; ?>" />
<param name="textcolour" value="<?php echo $textcolour; ?>" />
<param name="lanyardtext" value="<?php echo $lanyardtext; ?>" />
</object>

Doctype:(如果这跟它有什么关系的话?)

代码语言:javascript
复制
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

SVG代码:

代码语言:javascript
复制
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
 width="702px" height="259.37px" viewBox="0 0 702 259.37" enable-background="new 0 0 702 259.37" xml:space="preserve">
<g>
<g>
    <polygon fill="none" points="0,80.811 0.053,113.105 48.17,112.998 48.117,80.705         "/>

        <image overflow="visible" width="109" height="188" xlink:href="fitment1.png"  transform="matrix(4.854395e-04 0.2963 -0.2559 5.628683e-04 48.1172 80.7046)">
    </image>
</g>
</g>
<g>
<path fill-rule="evenodd" clip-rule="evenodd" fill="param(colour) white" d="M43.807,108.613c-0.241,0-0.476-0.086-0.659-0.248
    c-0.217-0.189-0.341-0.463-0.341-0.752v-22.26c0-0.502,0.372-0.926,0.87-0.991l633.935-83.34c0.043-0.005,0.086-0.008,0.129-0.008
    c0.264,0,0.52,0.104,0.707,0.293l22.26,22.26c0.188,0.188,0.293,0.442,0.293,0.707v61.08c0,0.553-0.447,1-1,1h-22.26
    c-0.553,0-1-0.447-1-1v-59.94L43.938,108.605C43.894,108.611,43.851,108.613,43.807,108.613z"/>
<path fill="#636466" d="M677.74,2.013L700,24.273v61.08h-22.26v-61.08l-633.933,83.34v-22.26L677.74,2.013 M677.74,0.013
    c-0.086,0-0.174,0.005-0.26,0.017L43.546,83.371c-0.995,0.13-1.739,0.979-1.739,1.982v22.26c0,0.576,0.248,1.125,0.681,1.504
    c0.367,0.322,0.836,0.496,1.319,0.496c0.086,0,0.174-0.006,0.261-0.016L675.74,26.553v58.8c0,1.104,0.896,2,2,2H700
    c1.105,0,2-0.896,2-2v-61.08c0-0.53-0.211-1.039-0.586-1.414l-22.26-22.26C678.777,0.222,678.268,0.013,677.74,0.013L677.74,0.013z
    "/>
</g>
<g>
<path fill-rule="evenodd" clip-rule="evenodd" fill="param(colour) white" d="M43.807,108.613c-0.552,0-1-0.447-1-1v-22.26c0-0.552,0.448-1,1-1
    H700c0.404,0,0.77,0.244,0.924,0.617c0.155,0.374,0.069,0.804-0.217,1.09l-22.26,22.26c-0.188,0.188-0.441,0.293-0.707,0.293
    H43.807z"/>
<path fill="#636466" d="M700,85.353l-22.26,22.26H43.807v-22.26H677.74H700 M700,83.353h-22.26H43.807c-1.104,0-2,0.896-2,2v22.26
    c0,1.104,0.896,2,2,2H677.74c0.53,0,1.039-0.211,1.414-0.586l22.26-22.26c0.572-0.572,0.743-1.432,0.434-2.18
    C701.538,83.84,700.809,83.353,700,83.353L700,83.353z"/>
</g>
<rect x="0" y="186.505" fill-rule="evenodd" clip-rule="evenodd" fill="param(colour) white" width="702" height="70.865"/>
<path fill="#636466" d="M702,257.37H0v2h702V257.37z M702,186.505v-2l0,0H0v2H702"/>
<g>
<defs>
    <polygon id="SVGID_1_" points="677.74,107.613 43.807,107.613 43.807,85.353 677.74,85.353 700,85.353         "/>
</defs>
<clipPath id="SVGID_2_">
    <use xlink:href="#SVGID_1_"  overflow="visible"/>
</clipPath>
<g clip-path="url(#SVGID_2_)">
    <text transform="matrix(1 0 0 1 372 102.272)" fill="param(textcolour) white" font-family="'Verdana-Bold'" font-size="16" text-anchor="middle" content-value="param(lanyardtext)">Enter Your Text          Enter Your Text          Enter Your Text          Enter Your Text</text>
</g>
</g>
<g>
<defs>
    <rect id="SVGID_3_" x="0" y="186.505" width="702" height="70.865"/>
</defs>
<clipPath id="SVGID_4_">
    <use xlink:href="#SVGID_3_"  overflow="visible"/>
</clipPath>
<g clip-path="url(#SVGID_4_)">
    <text transform="matrix(1 0 0 1 350 240.0977)" fill="param(textcolour) white" font-family="'Verdana-Bold'" font-size="50.9319" text-anchor="middle" content-value="param(lanyardtext) white">Enter Your Text          Enter Your Text          Enter Your Text          Enter Your Text</text>
</g>
</g>

<script type="text/ecmascript" xlink:href="param.js" />
</svg>

我在想这可能是服务器设置的问题?有谁知道我该怎么解决它吗?

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-25 03:51:22

您发送的SVG数据的mime类型为text/plain。您需要重新配置web服务器,以便使用image/svg+xml的mime类型发送它。如何做到这一点取决于您所使用的web服务器。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15055865

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档