画一个矩形(非填充)。
属性 | 类型 | 默认值 | 必填 | 说明 | 最低版本 |
|---|---|---|---|---|---|
| x | Number | 是 | 矩形路径左上角的 x 坐标 | ||
| y | Number | 是 | 矩形路径左上角的 y 坐标 | ||
| width | Number | 是 | 矩形路径的宽度 | ||
| height | Number | 是 | 矩形路径的高度 |
Page({
onLoad() {
const canvasContext = swan.createCanvasContext('myCanvas');
canvasContext.setStrokeStyle('blue');
canvasContext.strokeRect(30, 30, 150, 75);
canvasContext.draw();
}
});