【发布时间】:2020-03-25 06:40:30
【问题描述】:
我正在升级到 Ember Octane,并且我知道 mixin 已被弃用。我将继续使用它们,直到我弄清楚如何更换它们。与此同时,我想将我的路线切换到使用新的类语法,而不是Route.extend。新的路由类语法是否支持路由混合?如果是,怎么做?
这与Ember Octane Upgrade How to pass values from component to controller有关
灰烬之前的辛烷值:
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
【问题讨论】:
-
是的,您可以在 Native 类语法中有限地使用
Mixins。本指南应该对您有所帮助:guides.emberjs.com/release/upgrading/current-edition/…
标签: javascript ember.js