我正在尝试制作一个共享局部渲染3个SVG图像,但当它进入浏览器时,它们看起来都像第一个。
这是创建的代码:
<a href="">
<svg width="76" height="76" viewBox="0 0 76 76" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>GitHub</title>
<g id="Canvas" transform="translate(1493 741)">
<g id="Vector">
<use xlink:href="#path0_fill" transform="translate(-1493 -740.815)" fill="#2B34E3"/>
</g>
</g>
<defs>
<path id="path0_fill" fill-rule="evenodd" d="M 22.1444 38.5311C 22.0763 38.5311 22.8917 40.2542 22.9144 40.2542C 24.6943 43.4256 28.1252 45.3971 33.9128 45.9441C 33.0873 46.5592 32.0951 47.7265 31.9575 49.0752C 30.9186 49.7345 28.8295 49.9525 27.2062 49.4496C 24.9303 48.745 24.0593 44.3244 20.6524 44.9546C 19.9152 45.0895 20.0616 45.5672 20.6991 45.9744C 21.738 46.6336 22.715 47.4592 23.4686 49.2151C 24.048 50.5639 25.2648 52.9727 29.1148 52.9727C 30.6422 52.9727 31.7126 52.7924 31.7126 52.7924C 31.7126 52.7924 31.7417 56.2349 31.7417 57.5735C 31.7417 59.1176 29.6185 59.5525 29.6185 60.295C 29.6185 60.5887 30.3216 60.6164 30.8858 60.6164C 32.0017 60.6164 34.323 59.7025 34.323 58.0979C 34.323 56.8235 34.3445 52.5391 34.3445 51.7878C 34.3445 50.1492 35.2395 49.6298 35.2395 49.6298C 35.2395 49.6298 35.3505 58.3777 35.0261 59.5525C 34.6449 60.9315 33.957 60.7361 33.957 61.3513C 33.957 62.2664 36.7517 61.5769 37.6782 59.5664C 38.3939 58.0046 38.0809 49.4193 38.0809 49.4193L 38.8446 49.4042C 38.8446 49.4042 38.8875 53.3332 38.861 55.1294C 38.8345 56.9899 38.7057 59.342 39.8317 60.4513C 40.5714 61.1811 42.9672 62.4605 42.9672 61.2908C 42.9672 60.6113 41.6544 60.0529 41.6544 58.2139L 41.6544 49.7496C 42.7034 49.7496 42.5456 52.5328 42.5456 52.5328L 42.6226 57.7046C 42.6226 57.7046 42.3904 59.5878 44.6991 60.3756C 45.5133 60.6567 47.2552 60.7324 47.3373 60.2622C 47.4193 59.792 45.2394 59.0924 45.2192 57.6353C 45.2065 56.7441 45.2596 56.2248 45.2596 52.3576C 45.2596 48.4903 44.7307 47.0609 42.8864 45.9214C 48.5769 45.3479 52.0999 43.9664 53.8154 40.2668C 53.9492 40.2706 54.516 38.5387 54.4415 38.5387C 54.8265 37.142 55.0348 35.4895 55.0752 33.5332C 55.0651 28.2265 52.4774 26.3496 51.9813 25.4685C 52.7134 21.4513 51.8576 19.6235 51.4612 18.9958C 49.9944 18.484 46.3603 20.313 44.3734 21.6013C 41.1369 20.6723 34.2927 20.7618 31.7265 21.8408C 26.9916 18.5143 24.486 19.0235 24.486 19.0235C 24.486 19.0235 22.8665 21.871 24.0581 26.0382C 22.5004 27.987 21.3391 29.366 21.3391 33.0202C 21.3403 35.0798 21.5878 36.9227 22.1444 38.5311ZM 0 0L 75.7377 0L 75.7377 75.6303L 0 75.6303L 0 0Z"/>
</defs>
</svg>
</a>
<a href="">
<svg width="76" height="76" viewBox="0 0 76 76" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Twitter</title>
<g id="Canvas" transform="translate(1493 629)">
<g id="Vector">
<use xlink:href="#path0_fill" transform="translate(-1493 -628.63)" fill="#2B34E3"/>
</g>
</g>
<defs>
<path id="path0_fill" fill-rule="evenodd" d="M 43.1288 23.0458C 39.8229 24.2471 37.7338 27.3454 37.9711 30.7361L 38.0506 32.0445L 36.7277 31.8845C 31.9146 31.2706 27.7086 29.1882 24.1376 25.6891L 22.3918 23.9534L 21.9425 25.2353C 20.9907 28.0929 21.5991 31.1105 23.5822 33.1399C 24.64 34.2618 24.4014 34.4219 22.5774 33.7538C 21.9425 33.5408 21.3871 33.3807 21.334 33.4601C 21.1497 33.6479 21.7834 36.0769 22.2858 37.0387C 22.9738 38.3748 24.3749 39.6819 25.9099 40.4571L 27.2062 41.071L 25.6725 41.0975C 24.1919 41.0975 24.1389 41.1239 24.2979 41.6861C 24.8268 43.4218 26.9159 45.2647 29.2436 46.0664L 30.8833 46.6261L 29.4556 47.4807C 27.34 48.7109 24.8533 49.4042 22.3666 49.4559C 21.175 49.4824 20.1967 49.5895 20.1967 49.6702C 20.1967 49.9361 23.4244 51.4311 25.3014 52.0198C 30.935 53.7555 37.6277 53.0067 42.6529 50.0433C 46.224 47.9332 49.7937 43.7408 51.4612 39.6807C 52.3612 37.5189 53.26 33.566 53.26 31.6714C 53.26 30.4424 53.3395 30.2824 54.8202 28.8139C 55.6937 27.9592 56.5129 27.0252 56.672 26.758C 56.937 26.25 56.9093 26.25 55.5611 26.7038C 53.313 27.5055 52.9949 27.3983 54.107 26.1971C 54.9262 25.3424 55.9058 23.7933 55.9058 23.3395C 55.9058 23.2601 55.5094 23.3924 55.0588 23.6332C 54.5829 23.9004 53.5251 24.3013 52.7311 24.5408L 51.3034 24.9958L 50.007 24.1134C 49.2926 23.6332 48.2891 23.0987 47.7589 22.9387C 46.4095 22.5655 44.3457 22.6185 43.1288 23.0458ZM 0 0L 75.7377 0L 75.7377 75.6303L 0 75.6303L 0 0Z"/>
</defs>
</svg>
</a>
<a href="">
<svg width="76" height="76" viewBox="0 0 76 76" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Instagram</title>
<g id="Canvas" transform="translate(1493 853)">
<g id="instagram">
<use xlink:href="#path0_fill" transform="translate(-1493 -853)" fill="#2B34E3"/>
</g>
</g>
<defs>
<path id="path0_fill" fill-rule="evenodd" d="M 75.7377 0L 0 0L 0 75.6302L 75.7377 75.6302L 75.7377 0ZM 53.6281 22.0783C 54.6815 23.1304 55.3254 24.1824 55.8082 25.4244C 56.2765 26.6226 56.5984 27.9961 56.6862 30.0125C 56.7887 32.0289 56.8032 32.6718 56.8032 37.8152C 56.8032 42.9297 56.7743 43.594 56.6876 45.5841L 56.6875 45.587L 56.6862 45.6178C 56.5984 47.6196 56.2765 49.0078 55.8082 50.2059C 55.3254 51.4479 54.6815 52.4999 53.6281 53.552C 52.5745 54.604 51.521 55.2469 50.2772 55.7291C 49.0774 56.1967 47.7019 56.5182 45.6826 56.6058C 43.6633 56.7081 43.0195 56.7227 37.8689 56.7227C 32.7489 56.7227 32.0823 56.6938 30.0911 56.6074L 30.0897 56.6074L 30.0552 56.6058C 28.0505 56.5182 26.6604 56.1967 25.4606 55.7291C 24.2168 55.2469 23.1632 54.604 22.1097 53.552C 21.0562 52.4999 20.4124 51.4479 19.9294 50.2059C 19.4612 49.0078 19.1393 47.6342 19.0515 45.6178C 18.9491 43.6014 18.9344 42.9585 18.9344 37.8152C 18.9344 32.7018 18.9634 32.0366 19.0499 30.0476L 19.0515 30.0125C 19.1393 28.0107 19.4612 26.6226 19.9294 25.4244C 20.4124 24.1824 21.0562 23.1304 22.1097 22.0783C 23.1632 21.0263 24.2168 20.3834 25.4606 19.9012C 26.6604 19.4336 28.0359 19.1122 30.0552 19.0245C 32.0745 18.9222 32.7183 18.9076 37.8689 18.9076C 42.9889 18.9076 43.6555 18.9365 45.6467 19.0229L 45.6481 19.0229L 45.6826 19.0245C 47.6873 19.1122 49.0774 19.4336 50.2772 19.9012C 51.521 20.3834 52.5745 21.0263 53.6281 22.0783ZM 52.6184 48.9639C 52.8818 48.3064 53.1891 47.2982 53.2769 45.4571L 53.2794 45.3996C 53.3652 43.4576 53.3939 42.8073 53.3939 37.8152C 53.3939 32.8447 53.3654 32.1927 53.2805 30.2565L 53.2805 30.2554L 53.2804 30.2534L 53.2769 30.1732C 53.1891 28.3322 52.8818 27.3386 52.6184 26.6664C 52.2672 25.7751 51.8575 25.1468 51.1991 24.4893C 50.5405 23.8317 49.8967 23.408 49.0188 23.072C 48.3604 22.8089 47.3507 22.5021 45.507 22.4144C 43.517 22.3121 42.9025 22.2975 37.8542 22.2975C 32.873 22.2975 32.2228 22.3259 30.2805 22.4109L 30.2014 22.4144C 28.3578 22.5021 27.3628 22.8089 26.6897 23.072C 25.7971 23.4226 25.1678 23.8317 24.5094 24.4893C 23.851 25.1468 23.4266 25.7897 23.0901 26.6664C 22.8267 27.324 22.5194 28.3322 22.4316 30.1732C 22.3292 32.1604 22.3146 32.7741 22.3146 37.8152C 22.3146 42.7856 22.3431 43.4376 22.428 45.3738L 22.428 45.3749L 22.4281 45.377L 22.4316 45.4571C 22.5194 47.2982 22.8267 48.2917 23.0901 48.9639C 23.4413 49.8552 23.851 50.4835 24.5094 51.1411C 25.1678 51.7986 25.8118 52.2223 26.6897 52.5584C 27.3481 52.8214 28.3578 53.1282 30.2014 53.2159C 32.1914 53.3182 32.7914 53.3328 37.8542 53.3328C 42.8359 53.3328 43.4824 53.3045 45.4115 53.22L 45.507 53.2159C 47.3507 53.1282 48.3457 52.8214 49.0188 52.5584C 49.9114 52.2077 50.5405 51.7986 51.1991 51.1411C 51.8575 50.4835 52.2819 49.8406 52.6184 48.9639ZM 28.1237 37.8151C 28.1237 32.4526 32.4841 28.0983 37.8542 28.0983C 43.2244 28.0983 47.5848 32.4526 47.5848 37.8151C 47.5848 43.1776 43.2244 47.5319 37.8542 47.5319C 32.4841 47.5319 28.1237 43.1776 28.1237 37.8151ZM 31.5331 37.8151C 31.5331 41.3073 34.3717 44.1273 37.8542 44.1273C 41.3368 44.1273 44.1755 41.2927 44.1755 37.8151C 44.1755 34.3229 41.3514 31.5028 37.8542 31.5028C 34.3571 31.5028 31.5331 34.3375 31.5331 37.8151ZM 47.9652 29.9832C 49.2178 29.9832 50.2332 28.9692 50.2332 27.7184C 50.2332 26.4675 49.2178 25.4536 47.9652 25.4536C 46.7125 25.4536 45.6971 26.4675 45.6971 27.7184C 45.6971 28.9692 46.7125 29.9832 47.9652 29.9832Z"/>
</defs>
</svg>
</a>
正如您所看到的,所有SVG都不同,但在渲染时它们看起来像这样:
答案 0 :(得分:3)
您必须将id更改为唯一名称,并将其正确引用到xlink:href
中 <use xlink:href="#path1_fill" ...
<path id="path1_fill" fill-rule=...
<use xlink:href="#path2_fill" ...
<path id="path2_fill" fill-rule=...