<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.setLineWidth(3); ctx.beginPath(); ctx.arc(150, 150, 50, 0, 2 * Math.PI); ctx.setFillStyle("#007AFF"); ctx.fill(); ctx.setGlobalAlpha(0.5); ctx.setShadow(10, 10, 15, "#333"); ctx.setFillStyle("red"); ctx.fillRect(150, 150, 100, 100); ctx.draw(); }, } } </script> <style lang="scss" scoped></style>