Javascript Ember Octane Route类是否支持使用mixin?
我正在升级到余烬辛烷值,我知道混合器已被弃用。我将继续使用它们,直到我找到替换它们的方法。同时,我想将我的路由切换到使用新的类语法,而不是Javascript Ember Octane Route类是否支持使用mixin?,javascript,ember.js,Javascript,Ember.js,我正在升级到余烬辛烷值,我知道混合器已被弃用。我将继续使用它们,直到我找到替换它们的方法。同时,我想将我的路由切换到使用新的类语法,而不是route.extend。新路由类语法是否支持路由混合?如果是,如何进行 这与 余烬前辛烷值: import Route from '@ember/routing/route'; import AbcAuthenticatedRouteMixin from '../../mixins/abc-authenticated-route-mixin'; expor
route.extend
。新路由类语法是否支持路由混合?如果是,如何进行
这与
余烬前辛烷值:
import Route from '@ember/routing/route';
import AbcAuthenticatedRouteMixin from '../../mixins/abc-authenticated-route-mixin';
export default Route.extend(AbcAuthenticatedRouteMixin, {
model() {
return {
oldPassword: '',
newPassword: '',
confirmPassword: ''
};
},
})
import Route from '@ember/routing/route';
import AbcAuthenticatedRouteMixin from '../../mixins/abc-authenticated-route-mixin';
export default class ChangePasswordRoute extends Route(AbcAuthenticatedRouteMixin, {
model() {
return {
oldPassword: '',
newPassword: '',
confirmPassword: ''
};
},
}) // I get an error here that says: '{' expected
余烬后辛烷值:
import Route from '@ember/routing/route';
import AbcAuthenticatedRouteMixin from '../../mixins/abc-authenticated-route-mixin';
export default Route.extend(AbcAuthenticatedRouteMixin, {
model() {
return {
oldPassword: '',
newPassword: '',
confirmPassword: ''
};
},
})
import Route from '@ember/routing/route';
import AbcAuthenticatedRouteMixin from '../../mixins/abc-authenticated-route-mixin';
export default class ChangePasswordRoute extends Route(AbcAuthenticatedRouteMixin, {
model() {
return {
oldPassword: '',
newPassword: '',
confirmPassword: ''
};
},
}) // I get an error here that says: '{' expected
对于Ember mixin系统,本机类语法没有直接的等价物。如果要在转换为辛烷值时继续使用mixin,可以将经典类扩展语法与本机类语法混合使用: 试一试 此外,一些新的框架类,如Glimmer组件,根本不支持Ember混合。将来,mixin将从框架中删除,而不会直接替换。对于使用mixin的应用程序,建议的路径是将mixin重构为其他模式,包括: 纯本机类,通过类继承共享功能。 可以在多个类中导入和使用的实用程序函数。 可注入多个类的服务,共享 它们之间的功能和状态
是的,您可以在本机类语法中有限地使用
mixin
。这本指南应该对你有所帮助:谢谢你的正确答案;详细说明;以及如何处理我的混音的建议。