我想在Angular項目中使用外部庫。 這是從https://github.com/bramstein/fontfaceobserver在Angular中導入JS庫
的文檔如果您使用NPM,您可以安裝字體外觀作爲觀察員依賴:
$ npm install fontfaceobserver
You can then require fontfaceobserver as a CommonJS (Browserify) module:
var FontFaceObserver = require('fontfaceobserver');
var font = new FontFaceObserver('My Family');
font.load().then(function() {
console.log('My Family has loaded');
});
庫使用require
進口,但角度不一樣,關鍵字。有沒有一些標準的導入庫的方法?
你嘗試:'進口「fontfaceobserver'',如果你的'fontfaceobserver'位於'node_modules'文件夾 –
工程。感謝所以基本上,如果它在node_modules,比你可以使用import關鍵字? – sanjihan