ApplicationRouteMixin中的init和sessionAuthenticated不能在一起
init and sessionAuthenticated in ApplicationRouteMixin can not be together
我被这个问题搞晕了:init
和sessionAuthenticated
在ApplicationRouteMixin
不能在一起!
在我的 routes/application.js 我有这样的东西:
import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';
import other from '../other';
export default Ember.Route.extend(ApplicationRouteMixin, {
init: function () {
otherJsImImportingMainFunction();
},
sessionAuthenticated() {
this.transitionTo('someRoute');
debugger;
}
actions: {
...
}
};
在这种情况下,我的代码不起作用。
我进行身份验证,然后从未调用 sessionAuthenticated()。
如果我注释掉 "init:" 效果很好。
如何解决这个问题?
我用这种方式导入的效果很好吗?
NOTE: If you do override init for a framework class like Ember.View, be sure to call this._super(...arguments) in your init declaration! If you don't, Ember may not have an opportunity to do important setup work, and you'll see strange behavior in your application.
我被这个问题搞晕了:init
和sessionAuthenticated
在ApplicationRouteMixin
不能在一起!
在我的 routes/application.js 我有这样的东西:
import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';
import other from '../other';
export default Ember.Route.extend(ApplicationRouteMixin, {
init: function () {
otherJsImImportingMainFunction();
},
sessionAuthenticated() {
this.transitionTo('someRoute');
debugger;
}
actions: {
...
}
};
在这种情况下,我的代码不起作用。
我进行身份验证,然后从未调用 sessionAuthenticated()。
如果我注释掉 "init:" 效果很好。
如何解决这个问题?
我用这种方式导入的效果很好吗?
NOTE: If you do override init for a framework class like Ember.View, be sure to call this._super(...arguments) in your init declaration! If you don't, Ember may not have an opportunity to do important setup work, and you'll see strange behavior in your application.