Why does it show error when using import
?
您尚未在文件中导入 lodash:
import _ from 'lodash';
but i don't want to import loadash, I will include it in my html page.
if you've already imported "lodash" in html page, you can use the declare
keyword in your typescript source like this:
declare var _: any;
_.map([1, 2, 3], function(el: number, index: number) {
// ...
});
The declare keyword is used for ambient declarations where you want to define a variable that may not have originated from a TypeScript file.
-- EDIT --
After a search , I found "lodash" type definition is available at: https://www.npmjs.com/package/@types/lodash
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.