将矩导入Angular会出错 [英] Importing moment into Angular gives error
本文介绍了将矩导入Angular会出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到以下错误:Module '".../node_modules/moment/moment"' has no exported member 'default'
使用
import * as _moment from 'moment';
import { default as _rollupMoment } from 'moment';
const moment = _rollupMoment || _moment;
import * as _moment from 'moment';
import { default as _rollupMoment } from 'moment';
const moment = _rollupMoment || _moment;
推荐答案
来自Moment文档:
From Moment's Docs:
注意:如果导入时遇到问题,请尝试添加 "allowSyntheticDefaultImports":编译器选项中为true 在您的tsconfig.json文件中,然后使用语法
Note: If you have trouble importing moment, try adding "allowSyntheticDefaultImports": true in compilerOptions in your tsconfig.json file and then use the syntax
这篇关于将矩导入Angular会出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文