利用创建canvas对象来获取
private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
将context对象传递给canvas对象,然后在回调函数中获取长宽数据
if(this.screen_height==0){ Canvas(this.context).width("100%").height("100%").position({x:0,y:0}) .onReady(()=>{ this.screen_width =this.context.width this.screen_height = this.context.height }) }
标签:获取,解决方案,screen,private,height,width,context,屏幕,arkui From: https://www.cnblogs.com/linweimu/p/17896125.html