"TypeError: this.types is not a function" when using "vuex-orm-decorators"

"TypeError: this.types is not a function" when using "vuex-orm-decorators"

我正在尝试使用来自 https://github.com/scotley/vuex-orm-decorators#readme

的 npm 包 'vuex-orm-decorators'

当我尝试插入数据库时​​,出现错误 TypeError: this.types is not a function

实体看起来像这样

import { Model } from "@vuex-orm/core";
import { NumberField, OrmModel, StringField } from "vuex-orm-decorators";

@OrmModel("races")
export default class Race extends Model {
  @NumberField()
  public ID!: number;

  @StringField()
  public Name!: string;
}

商店看起来像这样:

import Vue from "vue";
import Vuex from "vuex";
import { ORMDatabase } from "vuex-orm-decorators";

Vue.use(Vuex);

export default new Vuex.Store({
  .
  .
  .
  plugins: [ORMDatabase.install()]
});

此外,也许这是一个线索....在 Vuex-Orm 中,this.setters 返回一个值,但 this.setters('all') 返回未定义。

/**
 * Get all records.
 */
Model.all = function () {
   return this.getters('all')();
};

从看到未定义的基本字段和函数来看,似乎 vuex-orm 数据库没有正确设置。有任何想法吗?

我试图为 vuex-orm-decorators 创建一个 Whosebug 标签,但我还没有达到 1500 rep,所以我只是将它标记为 vuex-orm。

vuex-orm-decorators package in the implementation of the types function defined in Vuex-ORM Single Table Inheritance 文档中有一个小错误。

我创建了一个 fork in which I fixed this simple problem and created a pull request 来更新原始包。

最后,我必须指出,从我对这个包的深入研究来看,它还没有完全准备好 table Vuex-ORM 中内置的继承功能,但对于简单的用例来说仍然很棒。