タイムゾーンを含む時計をアプリケーションに作成していますが、このエラーが発生し、修正できない場合もあります。私は多くの経験がありません、ホームページは、選択された時計が表示されますが、時間帯があるページが表示されますそれは空白です、私は助けを待っています、ありがとう!エラー 'moment'が定義されていません。ember.jsのno-undef
- エンバー-CLI:2.13.1は
- ノード:6.0.0
- OS:Linuxのx64の
`詳細は警備員 訪問https://ember-cli.com/user-guide/#watchmanを開始できませんでした。 '楽器' に関する
Livereloadサーバは、外部モジュール '燃えさしデータ/ -debug' から輸入したが は
app/controllers/clock.js
14:36 error 'moment' is not defined no-undef
18:27 error 'moment' is not defined no-undef
25:15 error 'moment' is not defined no-undef
✖ 3 problems (3 errors, 0 warnings)
app/controllers/timezones.js
7:23 error 'moment' is not defined no-undef
9:19 error 'moment' is not defined no-undef
10:21 error 'moment' is not defined no-undef
✖ 3 problems (3 errors, 0 warnings)
Build successful (4919ms) – Serving on http://localhost:4200/
Slowest Nodes (totalTime => 5%) | Total (avg)
----------------------------------------------+---------------------
Babel (17) | 1460ms (85 ms)
Rollup (1) | 1214ms
EslintValidationFilter (2) | 835ms (417 ms)
Concat (8) | 585ms (73 ms)
TreeMerger (allTrees) (1) | 312ms`
アプリ/コントローラ/ timezones.js
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].offsets[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();
}
}
});
を使用されることはありませんapp/controllers/clock.js
import Ember from 'ember';
export default Ember.Controller.extend({
init: function() {
// Update the time.
this.updateTime();
},
updateTime: function() {
var _this = this;
// Update the time every second.
Ember.run.later(function() {
_this.set('localTime', moment().format('h:mm:ss a'));
_this.get('model').forEach(function(model) {
model.set('time',
moment().tz(model.get('name')).format('h:mm:ss
a'));
});
_this.updateTime();
}, 1000);
},
localTime: moment().format('h:mm:ss a')
});
APP /モデル/ timezone.js
import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('string'),
offset: DS.attr('number')
});
APP /ルート/ clock.js
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return this.get('store').findAll('timezone');
}
});
APP /ルート/ timezones.js
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return this.get('store').findAll('timezone');
}
});
これ以上のファイルが必要な場合jus t talk
:、あなただけの世界的な瞬間をインポートするだろうか? –
あなたは、あなたのプロジェクトに '瞬間'グローバル変数を追加するbowerを通して瞬間をインポートしているように聞こえます。プロジェクトは、この変数が存在することをリンターが知らないので、あなたはそれが存在することを伝える必要があります(http://jshint.com/docs/)。 – locks