小程序开放平台

文档中心
暂无目录

xhs.fillRect

更新时间:2025-12-09 11:01:32

填充一个矩形。

参数

Number rotate

属性
类型
默认值
必填
说明
最低版本
xNumber矩形路径左上角的 x 坐标
yNumber矩形路径左上角的 y 坐标
widthNumber矩形路径的宽度
heightNumber矩形路径的高度

示例代码

Page({
    onLoad() {
        const canvasContext = xhs.createCanvasContext('myCanvas');
        canvasContext.setFillStyle('blue');
        canvasContext.fillRect(30, 30, 150, 75);
        canvasContext.draw();
    }
});

该文档是否对您有帮助?