亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從 npm 包中導入 Angular 模塊

從 npm 包中導入 Angular 模塊

開心每一天1111 2021-11-04 16:08:32
我想在應用程序中使用detect-mobile包(https://github.com/hgoebl/mobile-detect.js/tree/v1.4.4)Angular。但它不能以通常的方式導入。我已經嘗試了以下每一項:import { MobileDetect } from 'mobile-detect';import MobileDetect from 'mobile-detect';import {}  from 'mobile-detect';移動檢測d.ts文件具有以下結構:我做錯了什么,應該如何導入?此外,我將不勝感激解釋此類軟件包與其他軟件包的不同之處。Stackblitz:https ://stackblitz.com/edit/angular-3qptjt
查看完整描述

1 回答

?
小怪獸愛吃肉

TA貢獻1852條經驗 獲得超1個贊

用于導出的語法 - export = MobileDetect- 表示包是使用 CommonJS 樣式導出編寫的。請參閱這張票以獲得進一步的解釋。

因此,導入它的方法是:

import * as MobileDetect from 'mobile-detect'

另外,我相信如果您使用的是esModuleInteropTypeScript 編譯器標志,您可以只寫:

import MobileDetect from 'mobile-detect'


查看完整回答
反對 回復 2021-11-04
  • 1 回答
  • 0 關注
  • 181 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號