LoginSignup
0
0

More than 5 years have passed since last update.

XTemplateクラスでHello World

Last updated at Posted at 2014-08-28

Sencha TouchのXTemplateクラスでHello World的に簡単なサンプル。

ループを使わない例

Helloworld.js
Ext.define('CarouselTest.view.Helloworld',{
    extend: 'Ext.Container',
    xtype: 'helloworld',
    config: {
        data: {
            greeting: 'Hello World'
        },
        tpl: Ext.create('Ext.XTemplate', 
                '<tpl>',
                    '<p>{greeting}</p>',
                '</tpl>'
            )
    }
})

ループを使う例

Helloworld.js
Ext.define('CarouselTest.view.Helloworld',{
    extend: 'Ext.Container',
    xtype: 'helloworld',
    config: {
        data: {
            users: [  
                {
                    greeting: 'Hello',
                    name: 'World',
                },
                {
                    greeting: 'Welcome',
                    name: 'New World'
                }
            ]
            // greeting: 'Hello World'
        },
        tpl: Ext.create('Ext.XTemplate', 
                '<tpl for="users">',
                    '<div>{greeting} {name}</div>',
                '</tpl>',
                {
                    // join: function(value) {
                    //  return value(', ');
                    // }
                }
            )
        // tpl: Ext.create('Ext.XTemplate', 
        //      '<tpl>',
        //          '<p>{greeting}</p>',
        //      '</tpl>'
        //  )
    }
})

なぜ、forループを回す場合にはExt.Xtemplateのインスタン化にからメソッドが必要なのかがわからない。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0