sencha 2.0 mvc框架中如何切换页面(switch view)
2012-01-18 14:47
417 查看
Sencha Touch 交流 QQ 群 224711028 欢迎您的加入。
效果如下:
点击button后,右方页面跳转,如下图:
至于如何实现:
1.首先,请使用sencha论坛管理员201212月放出的mvc框架
下载地址:http://www.sencha.com/forum/showthread.php?162016-Simple-MVC-example
2.然后在view文件夹中新建两个view,代码如下:
3.将其中一个页面写入viewport页面之中
4.在controller端对button的函数进行设定:
5.如此,对于没有docked属性的item项,sencha会默认为1.1中的dockeditem项,这样便可以只切换item项而不惊动原有的dockeditem项。
6.如果是tabpanel的切换的话,用上述方法可能会报错:“Adding a card to a tab container without specifying any tab configuration”,不用急那是缺少tab配置项的问题,加入
即可
效果如下:
点击button后,右方页面跳转,如下图:
至于如何实现:
1.首先,请使用sencha论坛管理员201212月放出的mvc框架
下载地址:http://www.sencha.com/forum/showthread.php?162016-Simple-MVC-example
2.然后在view文件夹中新建两个view,代码如下:
Ext.define('MVCTest.view.List', { extend : 'Ext.Panel', xtype : 'mvctest-list', config : { // itemTpl : '{name}', // onItemDisclosure : function() {} //In PR3, this doesn't take a bool value, it will on next release items:[{ xtype:'button', id:'btn', text:'dfdsf' }] } // constructor : function(config) { // Ext.apply(config, { // store : Ext.create('MVCTest.store.Pages') //I don't like using storeId (or any other id) so I create the store class });
Ext.define('MVCTest.view.Page', { extend : 'Ext.Panel', xtype : 'mvctest-page', config : { // cls : 'page-detail', // tpl : '<div class="name">{name}</div><div class="content">{content}</div><div class="image-detail"><img src="{image}" /></div>' html:'<p>nb了lz</p>' } });
3.将其中一个页面写入viewport页面之中
Ext.define('MVCTest.view.Viewport', { extend : 'Ext.Container', xtype : 'mvctest-viewport', config : { fullscreen : true, layout : 'card', items : [ { xtype : 'toolbar', docked : 'top', //title : 'Title', defaultTitle : 'Title', items : [ { text : 'Back', ui : 'back', hidden : true } ] }, /** * Here you can specify any items on the bottom toolbar */ { // xtype : 'toolbar', // docked : 'bottom', // title : 'Bottom' width:400, xtype : 'navigatorPanel', docked:'left' }, { xtype : 'mvctest-listwrap' } ] } });
4.在controller端对button的函数进行设定:
'mvctest-list #btn':{ tap:function(){ var me = this, //list = me.getPageList(), viewport = me.getViewport(), //topToolbar = viewport.down('toolbar[docked=top]'), newCard = viewport.add({ xtype : 'mvctest-page', //data : record.data }); //list.deselect(record); viewport.setActiveItem(newCard); //topToolbar.setTitle(record.get('name')); } }
5.如此,对于没有docked属性的item项,sencha会默认为1.1中的dockeditem项,这样便可以只切换item项而不惊动原有的dockeditem项。
6.如果是tabpanel的切换的话,用上述方法可能会报错:“Adding a card to a tab container without specifying any tab configuration”,不用急那是缺少tab配置项的问题,加入
title: 'Tab 1', //html: '1', //cls: 'card1', iconCls: 'bookmarks',
即可
相关文章推荐
- viewpager 切换到前面的页面出现空问题
- Android ViewPager多页面滑动切换以及动画效果
- Android例子—Fragment实例讲解—底部导航栏+ViewPager滑动切换页面
- 这个例子主要展示了通过滑动实现viewflipper页面切换
- jQuery万能图片切换插件powerSwitch应用(支持同一页面多次调用)
- Android切换页面效果的实现二:WebView+ViewPager
- ViewPager多页面滑动切换以及动画效果 (转载)
- 安卓视频播放API--VideoView如何加载项目视频资源,如何全屏播放,如何作为欢迎页面的背景显示?
- Fragment的控制-切换View和页面替换
- 实现页面切换(动画效果实现,不用ViewPager)
- 如何在ngbtabset切换tab时不销毁页面只做隐藏
- ViewPager使用1-ViewPager多页面滑动切换以及动画效果(ViewPager+Layout+PagerAdapter )
- Android开发中如何解决Fragment +Viewpager滑动页面重复加载的问题
- ViewPager+Fragment滑动切换页面(RadioButton底部导航栏)
- 如何利用ViewPager、Fragment、PagerTabStrip实现多页面滑动效果
- ViewPager多页面滑动切换以及动画效果 (转载)
- Android面试题-终极解决ViewPager.setCurrentItem中间很多页面切换方案
- ViewPager (下)-- 利用 Fragment 实现美丽的 页面切换
- ViewPager可滑动页面+点击标题栏切换视图
- Vue 2.0 页面刚启动时如何做路由的重定向?