我将一个IndexedDb包装器(localForage)换成另一个(Dexie),但我无法运行该应用程序,因为在ExtJs框架中集成该应用程序的推荐方法不适合我。我做错了什么?
我当前的ExtJs版本: 框架:6.6.0.58 Cmd:v6.6.0.13 Dexie版本是最新的
Dexie文档建议您像这样设置数据库
var db = new Dexie("MyDatabase");
db.version(1).stores({
myStoreName, "++id, indexOne, indexTwo",
myOtherStoreName, "++id, indexOne, indexTwo",
});
myExtJsFile.js
Ext.define('DataLayer.Inferface', {
extend: 'Ext.Component',
xtype: 'DLInterface',
config: {
stuff...
db: new Dexie("mydatabaseName"),
}
ExtJs文档建议使用外部库的方式是在js数组的app.json文件中引用它
app.json
"js": [
{
"path": "${framework.dir}/build/ext-all-rtl-debug.js"
},
{
"path": "dexie.js" //Dexie is located in the same folder as app.json
},
我获得了成功的构建,但是当我部署它(在本地运行)时,却收到了此问题标题中列出的运行时错误。我知道VSCode中的intellisense不能很好地工作,所以当我似乎无法访问全局Dexie对象时,我并没有考虑太多。 我尝试了几种不同的方法,并使用m = no运气来加载该库。我会使用CDN,但它是一款具有脱机功能的应用程序,因此我真的希望在本地使用该库。我应该如何获取,引用和使用Ext中的第三方库?
谢谢。
答案 0 :(得分:0)
如果您在Ext.define中使用外部库,请尝试在extjs库(ext-all-rtl-debug.js
,app.js
等)之前包含外部库。
另一种解决方案-不要在类定义上附加远程库-请改用initialize / initComponent。示例:
Ext.define('DataLayer.Inferface', {
extend: 'Ext.Component',
xtype: 'DLInterface',
config: {
stuff...
},
initComponent: function () {
this.db=new Dexie("mydatabaseName");
this.callParent(arguments);
}