在商店里,我有两个相关的模型:Company
和User
用户
import { Model } from '@vuex-orm/core';
import { Company } from './models';
export class User extends Model {
static entity = 'users';
static fields() {
return {
company: this.belongsTo(Company, 'company_id'),
};
}
}
export default User;
公司
import { Model } from '@vuex-orm/core';
import { User } from './models';
export class Company extends Model {
// This is the name used as module name of the Vuex Store.
static entity = 'companies';
static fields() {
return {
account_manager: this.belongsTo(User, 'account_manager_id'),
};
}
}
export default Company;
为了避免依赖循环,我密切关注https://vuex-orm.org/guide/model/single-table-inheritance.html#solution-how-to-break-cyclesCompany
中的解决方案并
导入User
到models.js
楷模
export * from './company';
export * from './user';
然而,我仍然从 linter 中得到依赖循环错误。
我没有主意了。
代码示例:https ://github.com/mareksmakosz/vuex-orm-dependency-cycle