【求助】数组遍历问题
·
在api8环境下开发的。
想要已开发的app作为udp客户端,获得服务端回传的消息,并显示于接收区。
使用的数组为ArrayList,Scroll组件作为滚动,在想要遍历的时候出现问题。
private ArrayMessage:ArrayList<String> = new ArrayList()
'this.ArrayMessage' does not comply with the UI component syntax. <etsLint>
Row() {
Scroll(this.scroller) {
Flex({ direction: FlexDirection.Column }) {
this.ArrayMessage.forEach(this.ArrayMessage[0])
}.margin({ right: 15 })
}
.width('90%')
.scrollBar(BarState.Off)
.scrollable(ScrollDirection.Vertical)
.height("30%")
ScrollBar({ scroller: this.scroller, direction: ScrollBarDirection.Vertical,state: BarState.Auto }) {
Text()
.width(20)
.height(25)
.borderRadius(10)
.backgroundColor('#C0C0C0')
}.width(20).backgroundColor('#ededed').height("30%")
}
是需要加上什么东西吗?大佬们有什么更好地方法吗?还有就是ArratMessage前面是否需要加上@State,因为他变换的时候显示新收到的信息。
更多推荐
所有评论(0)