当svg的viewBox固定时,给g加上strokeWidth比较大的值时,会导致path的大小超出svg限定的大小,如何才能保证添加描边时,不让path大小超出svg。
<svg
height="100%"
id={`svg${random}`}
preserveAspectRatio="none"
version="1.1"
viewBox="0 0 144 101"
width="100%"
xmlns="http://www.w3.org/2000/svg"
xmlnsXlink="http://www.w3.org/1999/xlink"
>
<title>形状结合备份 5</title>
<g fill="none" stroke="none">
<g
fill={CustomProps.backgroundColor}
stroke={CustomProps.borderColor}
strokeWidth={50}
>
<path
d="M72,0.5 C91.7809891,0.5 109.692129,5.25981554 122.656174,12.9671914 C135.500604,20.603453 143.5,31.1362306 143.5,42.8053927 C143.5,54.4745547 135.500604,65.0073323 122.656174,72.6435939 C109.692129,80.3509698 91.7809891,85.1107853 72,85.1107853 C59.2534097,85.1107853 47.2836881,83.133806 36.9124278,79.6656594 C36.6718834,79.5852214 36.4311347,79.5036254 36.1905369,79.4216911 C36.2090595,79.6765963 36.2309708,79.9323386 36.2562723,80.1889169 C36.5209856,82.8733224 37.1317818,85.395488 38.0865315,87.7546951 C39.4360016,91.0892647 42.0562853,95.5245188 45.9525208,101.056345 C39.130986,98.7019239 33.2255441,94.6753065 28.2346538,88.9789085 C23.201662,83.2344576 19.90023,77.2093229 18.3391249,70.8991452 C7.18163245,63.1831864 0.5,53.4676415 0.5,42.8053927 C0.5,31.1362306 8.49939632,20.603453 21.3438256,12.9671914 C34.3078711,5.25981554 52.2190109,0.5 72,0.5 Z"
vectorEffect="non-scaling-stroke"
/>
</g>
</g>
</svg>
描边宽度为 50,你可以把 viewBox 的值从 0 0 144 101 更改为 -25 -25 194 151,这样应该可以