2017-04-03 47 views
0

我有一個使用REST API與Salesforce進行通信的Angular 1.5應用程序。我如何使用帶有<svg>和<use>標籤的SVG圖標

Salesforce的要求我們使用SVG的圖標,下面的語法:

<svg aria-hidden="true" class="slds-icon slds-icon--large slds-icon-standard-user"> 
    <use xlink:href="{!URLFOR($Asset.SLDS, 'assets/icons/standard-sprite/svg/symbols.svg#user')}"></use> 
</svg> 

在Salesforce沒有很好地工作。

我想在本地使用,以發展,但不工作。我嘗試下面的代碼:

<svg aria-hidden="true" class="slds-icon slds-icon--large slds-icon-standard-user"> 
    <use xlink:href="/path/to/the/icon.svg"></use> 
</svg> 

根據這一documentation我們需要在HTML元素中添加以下代碼:

<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> 

,但沒有運氣! :(

任何主意,用SVG與標籤和引用本地文件?

+0

「沒有運氣」究竟意味着什麼? –

+0

表示該圖標不顯示... – Francisco

+1

「使用本地」是指使用'file://'方案在開發計算機上進行測試嗎?如果是這樣,如果您在Chrome上進行測試,由於瀏覽器的安全功能,它可能無法正常工作。改用Firefox。 –

回答

相關問題