<template> <view class="zcvs"> <view class="zcvs-item"> <view>Canvas_旋转</view> <view> <canvas canvas-id="cvs" id="cvs" style="width: 400px; height: 400px;border: 1px solid #007AFF;" /> </view> </view> </view> </template> <script> export default { data() { return {}; }, onReady() { this.drawCvs(); }, methods: { drawCvs() { const ctx = uni.createCanvasContext(‘cvs‘); ctx.setFillStyle("#007AFF"); ctx.beginPath(); ctx.translate(200, 0); ctx.rotate(30 * Math.PI / 180); ctx.fillRect(0, 0, 100, 100); ctx.draw(); }, } } </script> <style lang="scss" scoped></style>