为什么';svg中的文本是否显示?

为什么';svg中的文本是否显示?,svg,Svg,我有一个简单的svg元素 <svg height="100" width="710"> <rect width="700" height="50"/> <rect width="70" height="50" style="fill: rgb(0, 0, 255);"> <text y="0" style="fill: white;">-0.123994</text> </rect>

我有一个简单的svg元素

<svg height="100" width="710">
  <rect width="700" height="50"/>
    <rect width="70" height="50" style="fill: rgb(0, 0, 255);">
      <text y="0" style="fill: white;">-0.123994</text>
    </rect>
    <rect width="70" height="50" style="fill: rgb(255, 0, 0);" transform="translate(630,0)">
    <text y="50">0.387869</text>
  </rect>
</svg>

-0.123994
0.387869
为什么两个
文本
元素都不显示?这就是它所显示的:

您不能在
rect
中放置
text
标记。如果要在rect元素中显示文本,应该将它们都放在一个组中

<svg height="100" width="710">
    <g>
    <rect width="70" height="50" style="fill: rgb(0, 0, 255);"></rect>
      <text y="0" style="fill: white;">-0.123994</text>
    </g>
    <g>
    <rect width="70" height="50" style="fill: rgb(255, 0, 0);" transform="translate(630,0)"></rect>
    <text y="50">0.387869</text>
   </g>

</svg>

-0.123994
0.387869

请调整文本坐标以显示在rect中。

对我来说,这是答案的一部分,但我还需要将文本对象转换为路径,然后将两个对象解组并删除我不再使用的对象: