Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html Svg过程参数_Html_Svg - Fatal编程技术网

Html Svg过程参数

Html Svg过程参数,html,svg,Html,Svg,我试图将参数传递给svg,但我没有做错什么,你能帮我一下吗 链接: Html: Svg: 好啊 编写规范的人注意到,虽然浏览器本身没有实现这一点,但您需要包含一个Javascript库。他们遗漏的是你应该把它包括在哪里。显然,您的第一个想法可能是将其包含在html文档中,但事实并非如此-它需要包含在.svg文件中,如下所示: <script type="text/ecmascript" xlink:href="https://dev.w3.org/SVG

我试图将参数传递给svg,但我没有做错什么,你能帮我一下吗

链接:

Html:


Svg:


好啊

编写规范的人注意到,虽然浏览器本身没有实现这一点,但您需要包含一个Javascript库。他们遗漏的是你应该把它包括在哪里。显然,您的第一个想法可能是将其包含在html文档中,但事实并非如此-它需要包含在.svg文件中,如下所示:

<script type="text/ecmascript" xlink:href="https://dev.w3.org/SVG/modules/ref/master/ref2.js"></script>
和button.svg:

<svg
    xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 110 40"
width="100%"
height="100%">
<defs>
    <ref id="paramX" param="fill" default="red"/>
    <ref id="paramY" param="stroke" default="blue"/>

</defs>
    <g>
        <rect 
id="button_rect" 
x="5" 
y="5" 
width="100" 
height="30" 
rx="15" 
ry="15" 
fill="url(#paramX)" 
stroke="url(#paramY)"
/>
<text 
id="button_label" 
x="55"
y="30"
text-anchor="middle" 
font-size="25"
fill="white"
font-family="Verdana" >
Go
</text>
    </g>
<script type="text/ecmascript" xlink:href="https://dev.w3.org/SVG/modules/ref/master/ref2.js"></script>
</svg>

您需要包含per。我尝试了包含per,您可以在codesanbox上看到它,但它不起作用。我尝试了各种方法,但没有成功。它似乎起作用,但如果我想将文本传递给文本组件,我该如何做:
<script type="text/ecmascript" xlink:href="https://dev.w3.org/SVG/modules/ref/master/ref2.js"></script>
<html>
  <head>
    <title></title>
    <meta charset="UTF-8" />
    <link rel="stylesheet" href="./style.css" />
  </head>
  <body>
    <object type="image/svg+xml" data="button.svg?fill=red">
      <param name="fill" value="blue" />
      <param name="stroke" value="red" />
    </object>
  </body>
</html>
<svg
    xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 110 40"
width="100%"
height="100%">
<defs>
    <ref id="paramX" param="fill" default="red"/>
    <ref id="paramY" param="stroke" default="blue"/>

</defs>
    <g>
        <rect 
id="button_rect" 
x="5" 
y="5" 
width="100" 
height="30" 
rx="15" 
ry="15" 
fill="url(#paramX)" 
stroke="url(#paramY)"
/>
<text 
id="button_label" 
x="55"
y="30"
text-anchor="middle" 
font-size="25"
fill="white"
font-family="Verdana" >
Go
</text>
    </g>
<script type="text/ecmascript" xlink:href="https://dev.w3.org/SVG/modules/ref/master/ref2.js"></script>
</svg>