0

当应用程序加载时,它会调用 app.js(这在 index.html 中调用)。我想要做的是当应用程序调用 app.js 时,我需要 app.js 来初始化 Main.js 视图。

简而言之,当 app.js 被调用时,它应该调用 Main.js 视图。

我怎样才能以编程方式做到这一点;

应用程序.js

    //<debug>
Ext.Loader.setPath({
                   'Ext': 'lib/touch/src'
                   });
    //</debug>

Ext.application({
                name: 'My',

                requires: [
                           'Ext.MessageBox'
                           ],

                views: ['Main'],

                icon: {


                phoneStartupScreen: 'resources/loading/Homescreen.jpg',
                tabletStartupScreen: 'resources/loading/Homescreen~ipad.jpg',

                launch: function() {
                // Destroy the #appLoadingIndicator element
                Ext.fly('appLoadingIndicator').destroy();

                // Initialize the main view
                Ext.Viewport.add(Ext.create('My.view.Main'));
                },

                onUpdated: function() {

                }
                });

主.js

Ext.define("My.view.Main", {
    extend: 'Ext.tab.Panel',
    requires: ['Ext.TitleBar'],

    config: {
        tabBarPosition: 'bottom',

        items: [
            {
                title: 'Welcome',
                iconCls: 'home',

                styleHtmlContent: true,
                scrollable: true,

                items: {
                    docked: 'top',
                    xtype: 'titlebar',
                    title: 'Welcome to Sencha Touch 2'
                },

                html: [
                    "You've just generated a new Sencha Touch 2 project. What you're looking at right now is the ",
                    "contents of <a target='_blank' href=\"app/view/Main.js\">app/view/Main.js</a> - edit that file ",
                    "and refresh to change what's rendered here."
                ].join("")
            },
            {
                title: 'Get Started',
                iconCls: 'action',

                items: [
                    {
                        docked: 'top',
                        xtype: 'titlebar',
                        title: 'Getting Started'
                    },
                    {
                        xtype: 'video',
                        url: 'http://av.vimeo.com/64284/137/87347327.mp4?token=1330978144_f9b698fea38cd408d52a2393240c896c',
                        posterUrl: 'http://b.vimeocdn.com/ts/261/062/261062119_640.jpg'
                    }
                ]
            }
        ]
    }
});
4

1 回答 1

2

做这个,

// Initialize the main view
Ext.Viewport.add({
     xclass:'My.view.Main'
});
于 2012-05-04T20:34:17.280 回答