Reactjs Dexiejs db.version().stores()在我的React应用程序中不初始化表,但在Codesandbox和StackBlitz中工作良好
我正在尝试用Dexie初始化indexedDB,它似乎在和中工作,但在我将代码移植到我的应用()时不工作。(数据库相关代码位于“考试历史记录”分支中) 在初始渲染时,触发器Reactjs Dexiejs db.version().stores()在我的React应用程序中不初始化表,但在Codesandbox和StackBlitz中工作良好,reactjs,typescript,react-redux,indexeddb,dexie,Reactjs,Typescript,React Redux,Indexeddb,Dexie,我正在尝试用Dexie初始化indexedDB,它似乎在和中工作,但在我将代码移植到我的应用()时不工作。(数据库相关代码位于“考试历史记录”分支中) 在初始渲染时,触发器TypeError:无法读取未定义的属性“mapToClass” 在StackBlitz中检查调试程序上的db时,它会将考试、答案和问题显示为表$$1。然而,在本地,它是未定义的 db.ts 记录“db” 在StackBlitz中记录“db” 看来修复程序是用db构造函数中的table方法替换mapToClass db.ex
TypeError:无法读取未定义的属性“mapToClass”
在StackBlitz中检查调试程序上的db时,它会将考试、答案和问题显示为表$$1。然而,在本地,它是未定义的
db.ts
记录“db”
在StackBlitz中记录“db”
看来修复程序是用db构造函数中的table方法替换mapToClass
db.exams = db.table("exams");
db.questions = db.table("questions");
db.answers = db.table("answers");
不过,如果有人能解释为什么mapToClass在codesandbox env中工作而不是在本地服务器中工作,我还是会很感激的
Dexie版本3.0.2
Typescript版本3.9.7
和tsconfig文件:
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"strictPropertyInitialization": false,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": [
"src"
]
}
能否提供有关本地设置的更多详细信息?例如,您是否使用SSR?@ukaszKarczewski使用CSR,前端使用js/react构建?您确定Dexie版本相同吗?在两个位置使用Dexie版本3.0.2您可以尝试删除
公共考试:Dexie.Table;公开问题:德克西.表;公众答案:德克西表代码>?
db.exams = db.table("exams");
db.questions = db.table("questions");
db.answers = db.table("answers");
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"strictPropertyInitialization": false,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": [
"src"
]
}