Polyline组件绘制坐标不准确?

@Entry 
@Component 
struct PolylineExample { 
  @State points:Array<Array<number>> = [[0,150], [75,100], [150,150],[225,200],[300,300]] 
  build() { 
    Column({ space: 10 }) { 
      // 在 100 * 100 的矩形框中绘制一段折线,起点(0, 0),经过(20,60),到达终点(100, 100) 
      Stack(){ 
        Polyline({ width: 300, height: 300 }) 
          .points(this.points) 
          .fillOpacity(0) 
          .stroke(Color.Blue) 
          .strokeWidth(3) 
        Circle({ width: 6, height: 6 }).position({x:297,y:147}) 
      } 
      .borderWidth(2).margin(50) 
    }.width('100%') 
  } 
}
阅读 155
1 个回答

Stack组件设置的 .margin(50) 导致Polyline组件大小被挤压,去掉margin(50)设置显示正常。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进