我正在尝试使用来自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 创建一个 stackoverflow 标签,但我还没有达到 1500 rep,所以我只是将它标记为 vuex-orm。