我正在创建一个身份验证来登录我的应用程序,但是我遇到了这三个问题,我不知道如何继续,我是新手,我不知道如何解决问题,我正在学习然而,在我按照这个过程后,我的应用程序不再出现,屏幕只是空白,教程是ember-simple-auth:http://ember-simple-auth.com/ - 提前谢谢你:
Could not start watchman
Visit https://ember-cli.com/user-guide/#watchman for more info.
Livereload server on http://localhost:49153
'instrument' is imported from external module 'ember-data/-debug' but
never used
/home/carlos/www/vendasapi-frontend/app/controllers/login.js
4:31 error 'session' is not defined no-undef
✖ 1 problem (1 error, 0 warnings)
/home/carlos/www/vendasapi-frontend/app/routes/application.js
2:8 error 'ApplicationRouteMix' is defined but never used no-
unused-vars
5:35 error 'ApplicationRouteMixin' is not defined no-undef
✖ 2 problems (2 errors, 0 warnings)
Build successful (4688ms) – Serving on http://localhost:4200/
Slowest Nodes (totalTime => 5% ) | Total (avg)
----------------------------------------------+---------------------
Babel (20) | 1481ms (74 ms)
Rollup (1) | 1352ms
EslintValidationFilter (2) | 703ms (351 ms)
Concat (8) | 545ms (68 ms)
应用/控制器/ login.js
import Ember from 'ember';
export default Ember.Controller.extend({
session: Ember.inject.service(session),
actions: {
authenticate() {
let { identification, password } =
this.getProperties('identification', 'password');
this.get('session').authenticate('authenticator:oauth2',
identification, password).catch((reason) => {
this.set('errorMessage', reason.error);
});
}
}
});
应用/控制器/ application.js中
import Ember from 'ember';
export default Ember.Controller.extend({
session: Ember.inject.service('session'),
actions: {
logout() {
this.get('session').invalidate();
}
}
});
应用/路由/ application.js中
import Ember from 'ember';
import ApplicationRouteMix from
'ember-simple-auth/mixins/application-route-mixin';
export default Ember.Route.extend(ApplicationRouteMixin);
答案 0 :(得分:0)
控制台输出确实解决了问题:
/home/carlos/www/vendasapi-frontend/app/controllers/login.js
4:31 error 'session' is not defined no-undef
你有session: Ember.inject.service(session)
。但是没有定义会话变量,因此您无法在其上调用Ember.inject.service
...您需要的是:
session: Ember.inject.service('session')
甚至:
session: Ember.inject.service()
/home/carlos/www/vendasapi-frontend/app/routes/application.js
2:8 error 'ApplicationRouteMix' is defined but never used no-
unused-vars
5:35 error 'ApplicationRouteMixin' is not defined no-undef
它说在第2行你导入为ApplicationRouteMix
,但你从来没有在任何地方使用它。然后在第5行,你正在使用ApplicationRouteMixin
,但没有在任何地方定义它。那只是因为你有一个错字 - 你想要使用的是:
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';