'ApplicationRouteMix' 已定义但从未使用 [Ember.js]

'ApplicationRouteMix' is defined but never used [Ember.js]

我正在创建一个身份验证来登录我的应用程序,但我遇到了这 3 个问题,我不知道如何继续,我是 ember 的新手,我不太了解如何修复问题,我正在学习它,在我遵循这个过程之后,我的应用程序不再出现,屏幕只变成空白,教程是 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)       

app/controllers/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);
      });

    }

  }

});

app/controllers/application.js

import Ember from 'ember';

export default Ember.Controller.extend({
  session: Ember.inject.service('session'),

   actions: {
     logout() {
      this.get('session').invalidate();
   }
 }
});

app/routes/application.js

import Ember from 'ember';
import ApplicationRouteMix from
'ember-simple-auth/mixins/application-route-mixin';

export default Ember.Route.extend(ApplicationRouteMixin);

控制台输出字面上拼出了问题:

  • /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';