“片刻"没有导出的成员“默认" [英] "moment" has no exported member 'default'

查看:91
本文介绍了“片刻"没有导出的成员“默认"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 moment.js 更改我的应用程序的本地日期格式,但出现以下错误:

时刻"在导入库时没有导出的成员默认".

下面是我的代码:

 从'@ angular/core'导入{Inject,Injectable,Optional};从'@ angular/material'导入{DateAdapter,MAT_DATE_LOCALE,MatDateFormats};从'moment'导入*作为_moment;从'moment'导入{默认为_rollupMoment,Moment};const moment = _rollupMoment ||_片刻; 

解决方案

尝试在您的 tsconfig.json 的"compilerOptions"下添加"allowSyntheticDefaultImports":true

I'm using moment.js to change the local date format for my application but getting the following error:

"moment" has no exported member 'default' when importing the library.

Below is my code:

import {Inject, Injectable, Optional} from '@angular/core';
import {DateAdapter, MAT_DATE_LOCALE, MatDateFormats} from '@angular/material';
import * as _moment from 'moment';
import {default as _rollupMoment, Moment} from 'moment';

const moment = _rollupMoment || _moment;

解决方案

Try adding "allowSyntheticDefaultImports": true to your tsconfig.json under the "compilerOptions"

这篇关于“片刻"没有导出的成员“默认"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆