Ela*_*nda 2 javascript momentjs
我有这个js代码:
toolFilters.filter('dateAccordingToTimeZone', function($filter) {
// Gets the number of milliseconds pass from 1970 and convert it to time according to given timezone, currently
// supported “Asia/Jerusalem” and “America/Los_Angeles”
return function(milliSeconds, timeZoneId) {
if (milliSeconds == 0) {
return "";
}
return moment().tz(milliSeconds, timeZoneId).format('MMM d, y H:mm:ss z'); // 5am PDT
};
})
Run Code Online (Sandbox Code Playgroud)
和这个 html
<script src="bower_components/moment/moment.js"></script>
Run Code Online (Sandbox Code Playgroud)
通过凉亭安装后
但我收到此错误:
VM9216:1 Uncaught TypeError: moment(...).tz is not a function
at eval (eval at <anonymous> (filters.js:31), <anonymous>:1:10)
at filters.js:31
at fn (eval at compile (angular.js:15551), <anonymous>:4:485)
at regularInterceptedExpression (angular.js:16658)
at expressionInputsWatch (angular.js:16579)
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
因为我基于官方文档
只是没有“要求”,因为我使用原生 js
时刻()。格式();Moment Timezone 是一个单独的模块,除了 moment 之外还需要安装。请参阅文档以了解如何安装它。
没有 tz模块的演示:
moment().tz();Run Code Online (Sandbox Code Playgroud)
<script src="https://momentjs.com/downloads/moment.js"></script>
</script>Run Code Online (Sandbox Code Playgroud)
带 tz模块的演示:
moment().tz();Run Code Online (Sandbox Code Playgroud)
<script src="https://momentjs.com/downloads/moment.js"></script>
<script src="https://momentjs.com/downloads/moment-timezone.min.js"></script>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10235 次 |
| 最近记录: |