Extjs:未介绍的参考:Dexie未在myjavascriptfile.js上定义:18



我正在将一个索引eddb包装器(localforage)换成另一个(dexie),我无法运行该应用程序,因为将其集成在Extjs框架中的推荐方法对我不起作用。我做错了什么?

我当前的版本/extjs: 框架:6.6.0.258 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 =没有运气来加载此库。我会使用CDN,但它是一个具有离线功能的应用程序,所以我真的希望本地库。我应该如何获得,参考和使用第三方库?

谢谢。

如果您在ext.define中使用外部库,请尝试在Extjs库之前包含外部库(ext-all-rtl-debug.jsapp.js等)。

另一种解决方案 - 不连接类定义的远程库 - 使用初始化/initcomponent。示例:

Ext.define('DataLayer.Inferface', {
extend: 'Ext.Component',
xtype: 'DLInterface',
config: {
    stuff...
},
initComponent: function () {
    this.db=new Dexie("mydatabaseName");
    this.callParent(arguments);
}

最新更新