2017-07-03 88 views
0

Uncaught SyntaxError: Unexpected token < sencha-touch.js:8618错误:即使他们的文件已部署煎茶触摸应用

Uncaught Error: The following classes are not declared even if their files have been loaded: 'Ext.Title'. Please check the source code of their corresponding files for possible typos: 'touch/src/Title.js at Object.onFileLoaded (sencha-touch.js:8618) at Object. (sencha-touch.js:3267) at HTMLScriptElement.onLoadFn (sencha-touch.js:8275)

回答

0

第一个错误说,一个特定的文件已加载,但不包含预期的JSON或JavaScript后,被载入”以下类未声明相反,该文件包含HTML或XML

第二个错误说,该文件touch/src/Title.js不包含Ext.define('Ext.Title', ...)如果下式成立

这两个错误发生在连续:。

  • 您的应用程序的某个地方使用Ext.Title
  • 您没有添加Ext.Title你需要一节,
  • 文件touch/src/Title.js没有在应用程序目录中存在和
  • Web服务器提供应用程序提供了一个HTML错误页面如果找不到文件。

只有当定义(Ext.define('Ext.Title')没有被编译到app.js时,你的应用程序才会尝试加载文件touch/src/Title.js

通常,潜在的问题是您在文件中缺少requires指令。 requires指令在编译时进行评估,并将组件添加到app.js,因此您的应用程序在运行时不会尝试加载Title.js。如果您将需求添加到使用它的组件:

Ext.define('MyOwnComponent',{ 
    requires: ['Ext.Title'], // <- add it here 
    constructor: function() { 
     Ext.create('Ext.Title'); // <- if it is used e.g. here 
    } 
}); 

并且再次编译您的应用程序,您应该很好。如果你不知道它在哪里使用,你可以将它添加到你的Application.js中,它也有一个require部分:

Ext.define('MyApplication',{ 
    extend: 'Ext.app.Application', 
    requires: ['Ext.Title'], // <- add it here 
    stores:[], 
    ... 
});