1 回答

TA貢獻1836條經驗 獲得超5個贊
Azure 徽章不打算與同一上下文中的其他徽章一起顯示,因為它們使用的 ID 并不唯一。
我正在構建一個 C# Razor 頁面應用程序,因此我在將 SVG 插入 Razor 頁面之前加載它們。為了解決這個問題,我通過 ReplaceIds 方法運行 SVG,然后將它們傳遞到 Razor 頁面:
private static string ReplaceIds(string text)
{
string pattern = " id=\"(\\w)\"";
while (true)
{
var res = Regex.Match(text, pattern, RegexOptions.IgnoreCase);
if (res.Success && res.Groups.Count > 0)
{
var id = res.Groups[1];
Guid g = Guid.NewGuid();
text = Regex.Replace(text, $" id=\"{id}\"", $" id=\"{g}\"");
text = Regex.Replace(text, @$"url\(#{id}\)", $"url(#{g})");
}
else
return text;
}
}
- 1 回答
- 0 關注
- 206 瀏覽
添加回答
舉報