我在我的解决方案中使用了 svg 图标作为自定义离子项目,如下所示。它适用于 web 视图但在模拟器或设备上运行良好,如下所示。
左侧是模拟器,右侧是网页视图
我的实现
角.json
....
"assets": [
{
"glob": "**/*",
"input": "src/assets",
"output": "assets"
},
{
"glob": "**/*.svg",
"input": "node_modules/ionicons/dist/ionicons/svg",
"output": "./svg"
},
{
"glob": "**/*.svg",
"input": "src/assets/icon/ion-icons",
"output": "./svg"
}
],
....
HTML
<ion-icon name="decrease"></ion-icon>
SVG
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="7" height="4" viewBox="0 0 7 4">
<defs>
<clipPath id="clip-path">
<path id="Shape" d="M2.793,3.5.146,6.146a.5.5,0,0,0,.707.707l3-3a.5.5,0,0,0,0-.707l-3-3A.5.5,0,0,0,.146.854Z"/>
</clipPath>
</defs>
<g id="Group_34" data-name="Group 34" transform="translate(7) rotate(90)" clip-path="url(#clip-path)">
<g id="COLOR_black" data-name="COLOR/ black" transform="translate(-4 -2.5)">
<rect id="COLOR_black_background" data-name="COLOR/ black background" width="12" height="12" fill="rgba(0,0,0,0)"/>
<rect id="Rectangle" width="12" height="12" fill="#0171ad"/>
</g>
</g>
</svg>
我已经放置了ios-decrease.svg
和md-decrease.svg
文件src/assets/icon/ion-icons
夹。