9 . 依次点击A、B、C、D四个按钮,其中不会触发UI刷新的是class Info {
name: string;
constructor(name: string) {
this.name = name;
}
}
@Entry
@Component
struct Index {
@State nameList: Info[] = [new Info("Tom"), new Info("Bob"), new Info("John")]
build() {
Column() {
ForEach(this.nameList, (item: Info) => {
Text(`${item.name}`)
Button("A")
.onClick(() => {
this.nameList.push(new Info("Lucy"));
})
Button("B")
.onClick(() => {
this.nameList[0] = new Info("Eric");
})
Button("C")
.onClick(() => {
this.nameList[0].name = "Jim";
})
Button("D")
.onClick(() => {
this.nameList = [new Info("Barry"), new Info("Cindy"), new Info("David")];
})
})
}
}
}