作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试在类里面使用时刻时区。这是我的打字。
"moment": "github:DefinitelyTyped/DefinitelyTyped/moment/moment.d.ts#a1575b96ec38e916750629839d2110cb96210f89",
"moment-timezone": "github:DefinitelyTyped/DefinitelyTyped/moment-timezone/moment-timezone.d.ts#f8a90040348e83926f44e690b209769c4f88b961"
我的导入:
import * as moment from 'moment';
import * as tz from 'moment-timezone';
我的用法:
var jun = moment("2014-06-01T12:00:00Z");
jun.tz('America/Los_Angeles').format('ha z');
我的错误:
Property 'tz' does not exist on type 'Moment'.
最佳答案
使用Typescript @types
打包并通过 import * as moment from 'moment-timezone';
导入它 您可以使用所有 moment
方法和成员变量作为 moment-timezone
导出它们。
我有一个使用 SystemJS 的完整示例 How to use moment-timezone in Angular2 via SystemJs
关于javascript - 如何在 Angular 2 类中使用时刻时区?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37540311/
我是一名优秀的程序员,十分优秀!