扫描小程序码分享
使用canvas做透明渐变,ios上正常,安卓手机上,背景色越透明,黑色越明显
3 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
https://developers.weixin.qq.com/community/develop/doc/000c0ef4548670076393518396b800
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
遇到问题+1
// index.wxml <view class="container"> <canvas id="myCanvas" type="2d" /> </view> // index.js const app = getApp() Page({ data: { }, onLoad: function() { wx.createSelectorQuery() .select('#myCanvas') // 在 WXML 中填入的 id .node(({ node: canvas }) => { const context = canvas.getContext('2d') // 填充背景色 context.fillStyle = 'rgb(255, 255, 255)' context.fillRect(10, 10, 150, 80) // Create linear gradient const grd = context.createLinearGradient(0, 0, 200, 0) grd.addColorStop(0, 'rgba(218, 230, 253, 1)') grd.addColorStop(1, 'rgba(255, 255, 255, 0)') // Fill with gradient context.fillStyle = grd context.fillRect(10, 10, 150, 80) }) .exec() }, })
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
https://developers.weixin.qq.com/community/develop/doc/000c0ef4548670076393518396b800
遇到问题+1