出于某种原因,我得到的是中文符号而不是正确的图标。我在 app/fonts 目录中有 .ttf,在 /app 下有 .css。希望你能发现我的错误
应用程序.css
.fa {
font-size: 60;
font-family: FontAwesome, fontawesome-webfont;
}
.ion {
font-family: Ionicons, ionicons;
font-size: 60;
}
main.ts
import { TNSFontIconService } from 'nativescript-ng2-fonticon';
nativeScriptBootstrap(AppComponent, [
HTTP_PROVIDERS,
provide(TranslateLoader, {
useFactory: () => {
return new TNSTranslateLoader('assets/i18n');
}
}),
TranslateService,
provide(TNSFontIconService, {
useFactory: () => {
return new TNSFontIconService({
'fa': 'font-awesome.css',
'ion': 'ionicons.css'
});
}
})
])
page.html
<Button class="fa" [text]="'fa-bluetooth' | fonticon"></Button>
<Label class="ion" [text]="'ion-flag' | fonticon"></Label>
页面.ts
import { TNSFontIconService, TNSFontIconPipe } from 'nativescript-ng2-fonticon';
@Component({
templateUrl: 'pages/pages/page.html',
pipes: [TranslatePipe, TNSFontIconPipe]
})
export class Pages {
constructor(private fonticon: TNSFontIconService,
private translate: TranslateService) {}