我想將 SVG 代碼存盤在一個單獨的檔案中,以便清理主代碼。
我在 <head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj 3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous">
</script>
<script>
$(function(){
$("icon").load("icon.xml");
});
</script>
我正在這樣呼叫檔案:
<div class="logo">
<a href="/""><div id="icon"></div></a>
</div>
但什么也沒有出現。此方法適用于我作為導航鏈接的單獨 html 參考。這種方法不支持其他檔案型別嗎?
uj5u.com熱心網友回復:
由于拼寫錯誤,SVG 無法顯示。這是修復:
<script src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj 3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous"></script>
<script>
$(function(){
$("#icon").load("icon.xml");
});
</script>
<div class="logo">
<a href="/"><div id="icon"></div></a>
</div>
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/416939.html
標籤:
下一篇:SVG影像無法在手機中正確顯示
