@State templateList: string[] = [];
aboutToAppear(): void {
let context = getContext(this) as common.UIAbilityContext;
context.resourceManager.getRawFileList("", (err: BusinessError, data: string[]): void => {
if (!data) {
return;
}
let list = data.filter((value:string) => {
return value.endsWith(".mist")
})
this.templateList = list.map<string>((value: string):string => {
return value.substring(0, value.length - 5);
});
})
}
build() {
//......
ForEach(this.templateList, (item:string):void => {
Text(item)
.width("100%").padding({ top:10, bottom: 10 })
.fontSize(18)
.onClick(event => {
})
Line().backgroundColor(Color.Black).width("100%").height(1)
})
//......
}
读取rawfile文件列表,并通过forEach渲染出列表,当rawfile中文件过多时,hidumper无法dump出组件树。
使用hidumper -s WindowManagerService -a '-w [winId] -default'可以输出,原因是element需要先写文件,再输出,文件过大会有问题。