📅  最后修改于: 2023-12-03 15:14:52.148000             🧑  作者: Mango
Ember.js是一个开源的JavaScript web框架,它专注于构建适当的、可伸缩的Web应用程序。下面是一些可能会在Ember.js面试中问到的问题。
import EmberRouter from '@ember/routing/router';
import config from './config/environment';
class Router extends EmberRouter {
location = config.locationType;
rootURL = config.rootURL;
}
Router.map(function() {
this.route('about');
});
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
export default class MyComponent extends Component {
@service myService;
constructor() {
super(...arguments);
this.myService.doSomething();
}
}
import Service from '@ember/service';
export default class MyService extends Service {
async fetchData() {
const response = await fetch('/api/data');
const json = await response.json();
return json;
}
}
import Mixin from '@ember/object/mixin';
export default Mixin.create({
init() {
console.log('Mixin initialized');
this._super(...arguments);
}
});
```javascript
import EmberRouter from '@ember/routing/router';
import config from './config/environment';
class Router extends EmberRouter {
location = config.locationType;
rootURL = config.rootURL;
}
Router.map(function() {
this.route('about');
});
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
export default class MyComponent extends Component {
@service myService;
constructor() {
super(...arguments);
this.myService.doSomething();
}
}
import Service from '@ember/service';
export default class MyService extends Service {
async fetchData() {
const response = await fetch('/api/data');
const json = await response.json();
return json;
}
}
import Mixin from '@ember/object/mixin';
export default Mixin.create({
init() {
console.log('Mixin initialized');
this._super(...arguments);
}
});