Sencha Touch - 带有图像的列表/nestesList
我今天早上开始使用 Sencha Touch,我需要一些帮助。
如果我创建一个像这样的嵌套列表:
var data = {
text: 'Groceries',
items: [{
text: 'Ninja',
items: [{
text: 'Water',
items: [{
text: 'Sparkling',
leaf: true
},{
text: 'Still',
leaf: true
}]
},{
text: 'Coffee',
leaf: true
},{
text: 'Espresso',
leaf: true
},{
text: 'Redbull',
leaf: true
},{
text: 'Coke',
leaf: true
},{
text: 'Diet Coke',
leaf: true
}]
}],{
text: 'Fruit',
items: [{
text: 'Bananas',
leaf: true
},{
text: 'Lemon',
leaf: true
}]
},{
text: 'Snacks',
items: [{
text: 'Nuts',
leaf: true
},{
text: 'Pretzels',
leaf: true
},{
text: 'Wasabi Peas',
leaf: true
}]
},{
text: 'Empty Category',
items: []
}]
};
如何将图像添加到列表中?例如,如果我想在减肥可乐旁边有可口可乐标志。我尝试设置 html 里面有一个图像,但这只是给了我一个空白项目。尽管有“文本”属性,但我找不到任何有关如何操作列表项的信息。我知道这是可能的,因为我看到了一个包含带有联系人照片的联系人列表的示例。
我希望你能帮助我并提前谢谢你。
I've started working with Sencha Touch this morning and I could use some help.
If I create a nestedList like this:
var data = {
text: 'Groceries',
items: [{
text: 'Ninja',
items: [{
text: 'Water',
items: [{
text: 'Sparkling',
leaf: true
},{
text: 'Still',
leaf: true
}]
},{
text: 'Coffee',
leaf: true
},{
text: 'Espresso',
leaf: true
},{
text: 'Redbull',
leaf: true
},{
text: 'Coke',
leaf: true
},{
text: 'Diet Coke',
leaf: true
}]
}],{
text: 'Fruit',
items: [{
text: 'Bananas',
leaf: true
},{
text: 'Lemon',
leaf: true
}]
},{
text: 'Snacks',
items: [{
text: 'Nuts',
leaf: true
},{
text: 'Pretzels',
leaf: true
},{
text: 'Wasabi Peas',
leaf: true
}]
},{
text: 'Empty Category',
items: []
}]
};
How can I add images to the list? For example if I wanted to have the Coca Cola Logo next to the string diet coke. I tried setting html whith an image inside but that just gave me a blank item. I can't find anything on how to manipulate list items despite the "text" property. I know it's possible though because I saw an example containing a contact list with contact photos.
I hope you can help me and thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以向
Ext.regModel
添加额外的字段,因此您需要添加一个字段来保存图像的路径。您可以将任何您想要的 HTML 添加到列表
itemTpl
中,以便您可以在其中添加图像。下面的示例来自 sencha api 文档,我将其修改为使用图像让您了解如何添加它们。
希望有帮助!
代码片段
You can add extra fields to your
Ext.regModel
, so you want to add one to hold the path to you image.You can add any HTML you want to the lists
itemTpl
so you can add your image in there.The example below is from the sencha api docs, I modified it to use images to give you an idea of how you can add them.
Hope that helps!
CODE SNIPPET