【问题标题】:Sencha touch 2.0 beta profiles does not workSencha touch 2.0 beta 配置文件不起作用
【发布时间】:2012-02-10 18:27:19
【问题描述】:

我是 sencha touch 的初学者,我正在尝试使用 sencha touch 配置文件运行演示应用程序这是代码

<!-- index.html-->
<!DOCTYPE html>
<html>
    <head>
       <title>MOIC Touch</title>
       <link rel="stylesheet" href="touch/resources/css/sencha-touch.css" type="text/css">
       <script type="text/javascript" src="touch/sencha-touch-all-debug.js"></script>
       <script type="text/javascript" src="app.js"></script>
    </head>
    <body></body>
</html>

//app.js
Ext.require([
     'MOICTouch.profile.Tablet']);
Ext.application({
    name: 'MOICTouch',
    profiles: ['Tablet']
});


//app/profile/Tablet.js
Ext.define('MOICTouch.profile.Tablet', {
      extend: 'Ext.app.Profile',

      config: {
         name: 'Tablet',
         views: ['Main']
      },

      isActive: function() {
         return Ext.os.is.Tablet;
      }
 });

当我运行 index.html 时,我在浏览器控制台中收到以下错误

Uncaught Error: Ext.Loader is not enabled, so dependencies cannot be resolved dynamically. Missing required class: MOICTouch.profile.Tablet

谁能帮帮我, 提前致谢

【问题讨论】:

  • 解决方案是让 Ext.loader 动态解析使用的类,您可以通过在 app.js 文件开头添加以下代码 sn-p 来做到这一点 Ext.Loader.setConfig({enabled :true});

标签: extjs sencha-touch sencha-touch-2


【解决方案1】:

正如您所提到的,您应该使用以下代码启用 Ext.Loader:

Ext.Loader.setConfig({ enabled: true });

但是,这只是因为您包含了 sencha-touch-all-debug.js。该文件包含整个框架,因此假定您不需要使用 Loader。

在开发中,你应该使用 sencha-touch-debug.js。这将默认启用 Ext.Loader,并且实际上会动态加载框架中您需要的每个类 - 而不是预先加载整个框架。

在 Sencha Touch API Docs - http://docs.sencha.com/touch/2-0/#!/guide/building

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-18
    • 1970-01-01
    • 2014-05-13
    • 2012-09-19
    相关资源
    最近更新 更多