对于下面的代码
Ext.define('ABC.view.ProductList',{
extend : 'Ext.Panel',
xtype : "productlist",
itemId : 'Productlist',
config : {
layout : {
type : 'fit'
}
},
initialize : function() {
var tpl = new Ext.XTemplate(
'<tpl for="suggestions">',
'<img src="{[this.image(values)]}">',
'<h1>{name}</h1>',
'<p>{description}</p>',
'<span>{globalPrice}</span>',
'</tpl>',{
image : function(value) {
var photoUrl = value.photoUrl;
var url = localStorage.httpPrefixAddress + photoUrl + '&token='+ localStorage.token;
return url;
}
}
);
var productList = Ext.create("Ext.List", {
itemId : 'Plist',
emptyText : 'Empty',
store : Ext.getStore('productStore'),
itemTpl: tpl
});
this.add(productList);
}
});
我得到了这样的输出,我的意思是它把每件事都显示为单个列表项。
早些时候,对于不同的项目,我在 sencha 论坛链接上提出了同样的问题
这是Json
"suggestions":[
{
"buckets":[
"Economy",
"Expensive"
],
"category":"Service",
"charge":100,
"class":"",
"description":null,
"gender":"Male",
"globalPrice":9.2,
"isPromotional":"N",
"longScript":null,
"name":"Universal-Adapter",
"photoUrl":Photo?productId=9",
"productId":9,
"rank":31,
"shortScript":null,
"uom":"Nos"
},
{
"buckets":[
"Expensive"
],
"category":"Electronic",
"charge":100,
"class":"",
"description":null,
"gender":"Male",
"globalPrice":99.99,
"isPromotional":"N",
"longScript":"ajkl mnopabcdefghijklm nopabcdefghijk",
"name":"Combination-Padlock",
"photoUrl":Photo?productId=1",
"productId":1,
"rank":29,
"shortScript":"abcdefghijklmnop",
"uom":"Nos"
},
{
"buckets":[
"Expensive"
],
"category":"Electronic",
"charge":100,
"class":"",
"description":null,
"gender":"Male",
"globalPrice":99.99,
"isPromotional":"N",
"longScript":null,
"name":"Luggage-Tags-PU-leat",
"photoUrl":"Photo?productId=3",
"productId":3,
"rank":29,
"shortScript":null,
"uom":"Nos"
},
{
"buckets":[
"Expensive"
],
"category":"Travel",
"charge":100,
"class":"",
"description":null,
"gender":"Male",
"globalPrice":6.8,
"isPromotional":"N",
"longScript":null,
"name":"Travel-Basic",
"photoUrl":"Photo?productId=5",
"productId":5,
"rank":29,
"shortScript":null,
"uom":"Nos"
},
{
"buckets":[
"Expensive"
],
"category":"Service",
"charge":100,
"class":"",
"description":null,
"gender":"Male",
"globalPrice":15.2,
"isPromotional":"N",
"longScript":null,
"name":"Travel-LED-Light",
"photoUrl":"Photo?productId=10",
"productId":10,
"rank":29,
"shortScript":null,
"uom":"Nos"
},
{
"buckets":[
"Economy",
"Expensive"
],
"category":"Electronic",
"charge":100,
"class":"",
"description":null,
"gender":"Female",
"globalPrice":40.9,
"isPromotional":"N",
"longScript":null,
"name":"Inflatable-Pillow",
"photoUrl":"Photo?productId=7",
"productId":7,
"rank":27,
"shortScript":null,
"uom":"Nos"
},
{
"buckets":[
"Economy",
"Expensive"
],
"category":"Service",
"charge":100,
"class":"",
"description":null,
"gender":"Female",
"globalPrice":25,
"isPromotional":"N",
"longScript":null,
"name":"Peg-Less-Washing-Lin",
"photoUrl":"Photo?productId=8",
"productId":8,
"rank":27,
"shortScript":null,
"uom":"Nos"
},
{
"buckets":[
"Expensive"
],
"category":"Travel",
"charge":100,
"class":"",
"description":null,
"gender":"Female",
"globalPrice":99.99,
"isPromotional":"N",
"longScript":null,
"name":"Dial-Lock-Strap",
"photoUrl":"Photo?productId=4",
"productId":4,
"rank":25,
"shortScript":null,
"uom":"Nos"
},
{
"buckets":[
"Expensive"
],
"category":"Electronic",
"charge":100,
"class":"",
"description":null,
"gender":"Female",
"globalPrice":2.8,
"isPromotional":"N",
"longScript":null,
"name":"Eye-Mask-and-Ear-Plu",
"photoUrl":"Photo?productId=6",
"productId":6,
"rank":25,
"shortScript":null,
"uom":"Nos"
},
{
"buckets":[
"Expensive"
],
"category":"Travel",
"charge":100,
"class":"",
"description":null,
"gender":"Female",
"globalPrice":99.99,
"isPromotional":"N",
"longScript":null,
"name":"Luggage-Tags-Plastic",
"photoUrl":"Photo?productId=2",
"productId":2,
"rank":25,
"shortScript":null,
"uom":"Nos"
}
]
@ThinkFloyd 这就是我得到的,我按照你说的尝试了
如您所见,有一条线用于设置高度