0

我这里有点糊涂,看下面的代码:

var arrReqTplTest=["........................."];
var finalStudent=[];
finalStudent.push({
title: “Student Table”,
                collapsed: true,
                layout: 'fit',
                items: [
                    {
                        xtype: 'component',
                        itemId: 'StudentTablViewID-' + i,
                        html: arrReqTplTest

                    },
                    {
                        xtype: 'dataview',
                        itemId: 'StudentTable-' + i,
                        height: 200,
                        store: ‘studentDetailStore’,
                        //itemHeight: 70,
                        scrollable: false,           
                        itemSelector: 'div.wrap-requirements-' + i
                    }
                ]
            });
        }

        view.add(finalStudent);
})
}
});

这工作正常,但现在看看下面的代码不起作用:

 var arrReqTplTest=["........................."];
    var finalStudent=[];
    finalStudent.push({
    title: “Student Table”,
                    collapsed: true,
                    layout: 'fit',
                    items: [
                        {
                            xtype: 'component',
                            itemId: 'StudentTablViewID-' + i,
                            config:{
                                    html:arrReqTplTest
                                }

                        },
                        {
                            xtype: 'dataview',
                            itemId: 'StudentTable-' + i,
                            height: 200,
                            store: ‘studentDetailStore’,
                            //itemHeight: 70,
                            scrollable: false,           
                            itemSelector: 'div.wrap-requirements-' + i
                        }
                    ]
                });
            }

            view.add(finalStudent);
    })
    }
    });
4

1 回答 1

0

这是因为“html”是组件配置的一部分。你用第一个代码做对了:

html: thisIsYourVariableWithHtml //you can store the html value inside a variable or directly paste the value as string

但我建议添加:

styleHtmlContent: true,

以确保该组件真正将 html 值呈现为 html。

现在在您编写的第二个代码中:

config: {
    html: thisIsYourVariableWithHtml
}

您正在定义自定义配置变量(不知道其他人怎么称呼它,但这是我在组件的配置对象中定义属性时的术语)在这种情况下,一个名为 config 的对象具有值“html”,默认情况下 sencha 的组件将不知道什么这样做,因为它是您的自定义配置变量。

于 2014-04-15T15:36:40.777 回答