我有repeater.js,m在其中获取加载值。这是setupItem方法..
我想在单击按钮时获得相同的值..如果列表和中继器都出现此问题...数据正在加载 onload 但在按钮上它不起作用...任何人都可以帮助...
enyo.kind({
name: "enyo.sample.RepeaterSample",
classes: "enyo-fit repeater-sample",
components: [
{kind: "Repeater", onSetupItem:"setupItem", components: [
{name:"item", classes:"repeater-sample-item", components: [
{tag:"span", name: "personNumber"},
{tag:"span", name: "personName"}
]}
]},
//{kind: "onyx.Button", content:"Fetch", ontap:"setupItem"}
],
create: function() {
this.inherited(arguments);
this.$.repeater.setCount(this.people.length);
this.peopleChanged();
},
published: {
people: []
},
peopleChanged: function() {
for(var i=0;i < 5;i++){
this.people[i]="art "+i;
}
this.$.repeater.setCount(this.people.length);
},
setupItem: function(inSender, inEvent) {
var index = inEvent.index;
var item = inEvent.item;
alert(this.people[index]);
var person = this.people[index];
//item.$.personNumber.setContent((index) + ". ");
item.$.personName.setContent(person);
//item.$.personName.applyStyle("color", person.sex == "male" ? "dodgerblue" : "deeppink");
},
});