小程序开放平台

文档中心
暂无目录

xhs.strokeRect

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

画一个矩形(非填充)。

参数

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

示例代码

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

该文档是否对您有帮助?