gpt4 book ai didi

javascript - 时刻时区和_zones

转载 作者:行者123 更新时间:2023-11-28 07:27:52 24 4
gpt4 key购买 nike

我是 JavaScript 新手。我刚刚在此页面中找到以下代码[https://developer.mozilla.org/en-US/Apps/Quickstart/Building_simple_functionality] 。虽然,我知道这些函数的作用,但我不清楚_zones是什么?谁能详细解释一下吗?

import Ember from 'ember';

export default Ember.Controller.extend({
/* create array of timezones with name & offset */
init: function() {
var timezones = [];
for (var i in moment.tz._zones) {
timezones.push({
name: moment.tz._zones[i].name,
offset: moment.tz._zones[i].offset[0]
});
}
this.set('timezones', timezones);
this._super();
},
selectedTimezone: null,
actions: {
/* save a timezone record to our offline datastore */
add: function() {
var timezone = this.store.createRecord('timezone', {
name: this.get('selectedTimezone').name,
offset: this.get('selectedTimezone').offset
});
timezone.save();
},
/* delete a timezone record from our offline datastore */
remove: function(timezone) {
timezone.destroyRecord();
}
}
});

谢谢

最佳答案

显然,_zone 是一个数组,是 moment.tz 对象的属性,其中包含所有区域,如果您对区域对象有疑问,我在下面留下了一个链接。下划线可能是由于使用前缀在 javascript 中实现私有(private)属性的常见技术所致。

http://momentjs.com/timezone/docs/#/zone-object/

关于javascript - 时刻时区和_zones,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29439392/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com