angular4中引入svg

阿里icon

直接放入assets文件夹后
html引入即可

<div>
    <img src="yourIcon.svg">
</div>

注意:
根位置是index.html文件所在的位置


动态更改svg

可以使用ngStyle指令

<circle [ngStyle]="{stroke:stroke, fill: fill}" 
    id="XMLID_1_" 
    class="st0" cx="91.2" cy="87.2" r="10"    
    (mouseover)="func1()"/>

<circle [style.stroke]="stroke"
        [style.fill]="fill" 
    id="XMLID_1_" 
    class="st0" cx="91.2" cy="87.2" r="10"    
    (mouseover)="func1()"/>

在angular中 尽量避免使用jquery


引入font-awesome

There are 3 parts to using Font-Awesome in Angular Projects

Installation
Styling (CSS/SCSS)
Usage in Angular
Installation

Install from NPM and save to your package.json

npm install --save font-awesome

Styling If using CSS

Insert into your style.css

@import '~font-awesome/css/font-awesome.css';
这里写代码片

Styling If using SCSS

Insert into your style.scss

$fa-font-path: "../node_modules/font-awesome/fonts";
@import '~font-awesome/scss/font-awesome.scss';

Usage with plain Angular 2.4+ 4+

<i class="fa fa-area-chart"></i>

结合Material一同使用

In your app.module.ts modify the constructor to use the MdIconRegistry


export class AppModule {
  constructor(mdIconRegistry: MdIconRegistry) {
    mdIconRegistry.registerFontClassAlias('fontawesome', 'fa');
  }
}

and add MdIconModule to your @NgModule imports

@NgModule({
  imports: [
    MdIconModule,
    ....
  ],
  declarations: ....
}

Now in any template file you can now do

<md-icon fontSet="fontawesome" fontIcon="fa-area-chart"></md-icon>

单独使用material

index.html

<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值