未验证 提交 2b8a1007 编写于 作者: O openharmony_ci 提交者: Gitee

!21975 修复grid示例代码拖拽图片显示错误的bug

Merge pull request !21975 from tomkl123/20230804_grid_code
...@@ -222,7 +222,7 @@ struct GridExample { ...@@ -222,7 +222,7 @@ struct GridExample {
@Entry @Entry
@Component @Component
struct GridExample { struct GridExample {
@State numbers: String[] = [] @State numbers: string[] = []
scroller: Scroller = new Scroller() scroller: Scroller = new Scroller()
@State text: string = 'drag' @State text: string = 'drag'
...@@ -258,11 +258,6 @@ struct GridExample { ...@@ -258,11 +258,6 @@ struct GridExample {
.width(80) .width(80)
.height(80) .height(80)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.onTouch((event: TouchEvent) => {
if (event.type === TouchType.Up) {
this.text = day
}
})
} }
}) })
} }
...@@ -277,6 +272,7 @@ struct GridExample { ...@@ -277,6 +272,7 @@ struct GridExample {
.height(300) .height(300)
.editMode(true) //设置Grid是否进入编辑模式,进入编辑模式可以拖拽Grid组件内部GridItem .editMode(true) //设置Grid是否进入编辑模式,进入编辑模式可以拖拽Grid组件内部GridItem
.onItemDragStart((event: ItemDragInfo, itemIndex: number) => { //第一次拖拽此事件绑定的组件时,触发回调。 .onItemDragStart((event: ItemDragInfo, itemIndex: number) => { //第一次拖拽此事件绑定的组件时,触发回调。
this.text = this.numbers[itemIndex]
return this.pixelMapBuilder() //设置拖拽过程中显示的图片。 return this.pixelMapBuilder() //设置拖拽过程中显示的图片。
}) })
.onItemDrop((event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => { //绑定此事件的组件可作为拖拽释放目标,当在本组件范围内停止拖拽行为时,触发回调。 .onItemDrop((event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => { //绑定此事件的组件可作为拖拽释放目标,当在本组件范围内停止拖拽行为时,触发回调。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册