在InitComponent EXTJS中使用Type

时间:2017-08-23 16:38:09

标签: javascript extjs xtype

我在使用EXTJS方面有点新,所以我正在使用一个教程(修改它以适应我的要求),而且我遇到了一个错误。这是教程代码(我不能发布我的实际代码,但它有相同的想法,只是不同的方法名称):

    Ext.define('Srchr.view.Viewport', {
        extend: 'Ext.Viewport',
        requires: [
            'Srchr.view.SearchBar',
            'Srchr.view.History',
            'Srchr.view.SearchResults'
        ],
        layout: {
            type: 'fit'
        },
        initComponent: function() {
            this.items = [
                xtype: 'panel',
                cls: 'srchr',
                this.dockedItems = [
                    this.createSearchBar(),
                    this.createHistory()
                ];
                this.items = [{
                    id: 'tabs',
                    xtype: 'tabpanel',
                    layout: 'fit',
                    items: [
                        this.createTwitterSearchResults(),
                        this.createAnswersSearchResults()
                    ]
                }]
            ];
            this.callParent(arguments);
        },
        createSearchBar: function() {
            this.searchBar = Ext.create('widget.searchbar', {
                dock: 'top',
                height: 60  
            });
            return this.searchBar;
        },
        createHistory: function() {
            this.history = Ext.create('widget.history', {
                id: 'history',
                dock: 'left',
                width: 320
            });
            return this.history;
        },
        createTwitterSearchResults: function() {
            this.twitterSearchResults = Ext.create('widget.searchresults', {
                id: 'twittersearchresults',
                title: 'Twitter Search Results Placeholder'
            });
            return this.twitterSearchResults;
        },
        createAnswersSearchResults: function() {
            this.answersSearchResults = Ext.create('widget.searchresults', {
                id: 'answerssearchresults',
                title: 'Answers Search Results Placeholder'
            });
            return this.answersSearchResults;
        }
    });

所以这就是问题:我在第14行xtype:'panel'上收到错误,表示“意外令牌:”。我已经尝试了所有我能想到的解决问题的方法,但找不到合适的解决方案。我怎样才能摆脱这个错误?

谢谢!

1 个答案:

答案 0 :(得分:2)

将您的小组项目用括号括起来:

this.items = [{
  xtype       : 'panel',
  cls         : 'srchr',
  dockedItems : [this.createSearchBar(), this.createHistory()]
}, {
  id     : 'tabs',
  xtype  : 'tabpanel',
  layout : 'fit',
  items  : [this.createTwitterSearchResults(), this.createAnswersSearchResults()]
}]

除此之外,您还使用tabpanel覆盖了item对象。如果要添加两个项目,请将两个项目放在数组中:

import tensorflow as tf

b = tf.constant([[True, False, True, False],[ False, False, True, False]])
x=tf.unstack(b)
c = [tf.squeeze(tf.where(e)) for e in x]

init_op = tf.global_variables_initializer()

with tf.Session() as sess:
    sess.run(init_op)
    print(sess.run([c]))