作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 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)属性的常见技术所致。
关于javascript - 时刻时区和_zones,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29439392/
我是一名优秀的程序员,十分优秀!