angular – 导入非打字稿npm模块的最佳解决方案
发布时间:2020-12-17 07:26:44 所属栏目:安全 来源:网络整理
导读:使用traceur和SystemJS使用ES6这种形式是正确的: import _ from 'lodash'; 对于Typescript它是不够的 – 我得到错误错误TS2307:找不到模块’lodash’所以,我安装’lodash.d.ts’: /// reference path="lodash/lodash.d.ts" /import _ from 'lodash'; 现在
使用traceur和SystemJS使用ES6这种形式是正确的:
import _ from 'lodash'; 对于Typescript它是不够的 – 我得到错误错误TS2307:找不到模块’lodash’所以,我安装’lodash.d.ts’: /// <reference path="lodash/lodash.d.ts" /> import _ from 'lodash'; 现在,我得到:模块’“lodash”’没有默认导出.来自Typescript编译器 所以,我尝试’节点样式’: /// <reference path="lodash/lodash.d.ts" /> let _ = require('lodash'); 我得到:未捕获(在承诺中)错误:require不是浏览器中的函数 最后: import _ = require('lodash'); 并且它有效,但它的’旧形式’不适合ES6. 对于非打字稿模块,是否有单一,正确的方法来使用ES6样式的Typescript导入? (打字稿1.6.2)
尝试从’lodash’导入*作为_;
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |