首页 > 解决方案 > 如何以 SVG 格式使用 xlink:href 传递参数?

问题描述

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:v="http://schemas.microsoft.com/visio/2003/SVGExtensions/" width="70.4094in" height="34.0787in"
viewBox="0 0 20000 10000" xml:space="preserve" color-interpolation-filters="sRGB" class="st238">

      <defs>

        <g id="text1">
        <title>  </title>
        <v:textRect cx="0" cy="0" width="19.2" height="0"/>
        <text x="0" y="0"> text to display </text>
        </g>
         </defs>



         <g>

          <use x="100" y="100" xlink:href="#text1"/>
          <use x="200" y="200" xlink:href="#text1"/>

         </g>



</svg>

在我的代码中,我在 use 和 xlink 中使用了同一个对象两次,你知道我如何通过 xlink 传递参数(例如文本的参数而不是显示“要显示的文本”)吗?

标签: svgxlink

解决方案


推荐阅读