zoukankan      html  css  js  c++  java
  • 使用 append 方法追加元素

    来自于《sencha touch 权威指南》

    学习使用 Ext.DomHelper 组件在页面中追加元素。app.js代码如下:

    Ext.require(['Ext.form.Panel','Ext.Toolbar']);
    Ext.application({
        name: 'MyApp',
        icon: 'images/icon.png',
        glossOnIcon: false,
        phoneStartupScreen: 'images/phone_startup.png',
        tabletStartupScreen: 'images/tablet_startup.png',
        
        launch: function(){
            function appendDom(){
                Ext.DomHelper.append('my-div',{
                    id: 'url-list',
                    tag: 'ul',
                    cn:[{
                        tag: 'li',
                        cn: [{
                            tag: 'a',
                            html: 'google',
                            href: 'http://www.baidu.com/'
                        }]
                    },{
                        tag: 'li',
                        cn: [{
                            tag: 'a',
                            html: 'sina',
                            href: 'http://www.sina.com.cn/'
                        }]
                    }]
                });
            }
    
            var myToolbar = Ext.create('Ext.Toolbar',{
                docked: 'top',
                items: [{
                    xtype: 'button',
                    text: '追加元素',
                    handler: function(){
                        appendDom();
                    }
                }]
            });
    
            var MyPanel = Ext.create('Ext.Panel',{
                id: 'MyPanel',
                title: '通过DomHelper组件追加元素',
                html: '<div id="my-div"></div>',
                items: [myToolbar]
            });
    
            Ext.Viewport.add(MyPanel);
        }
    });

     显示效果:

  • 相关阅读:
    2020 HDU校赛 Problem J
    2020 HDU校赛 Problem I
    2020年HDU校赛 Problem A
    HDU 2553 N皇后 (dfs+回溯)
    D
    #6177. 「美团 CodeM 初赛 Round B」送外卖2(floyed + 三进制枚举 )
    E
    B
    大数加法模板(可能有问题,目前没发现)
    H
  • 原文地址:https://www.cnblogs.com/phpway/p/3454848.html
Copyright © 2011-2022 走看看