小程序
小游戏
企业微信
微信支付
扫描小程序码分享
3 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
不随页面滚动是什么意思?
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
楼主这个问题现在解决了吗?
看一下你的定位样式
html:<canvas id="myCanvas" type="2d" style="width: 300px; height: 150px;"></canvas>
draw(step, totalStep) {
const query = mpvue.createSelectorQuery();
query.select("#myCanvas")
.fields({ node: true, size: true })
.exec((res) => {
const canvasObj = res[0].node;
const canvasCtx = canvasObj.getContext("2d");
canvasCtx.clearRect(0, 0, 600, 600);
canvasCtx.beginPath();
canvasCtx.arc(mpvue.getSystemInfoSync().windowWidth / 2, 80, 70, Math.PI * 0.75, Math.PI * 2.25, false); // 绘制外侧圆弧
canvasCtx.strokeStyle = "#ededed";
canvasCtx.lineCap = "round";
canvasCtx.lineWidth = 10;
canvasCtx.stroke();
canvasCtx.arc(mpvue.getSystemInfoSync().windowWidth / 2, 80, 70, Math.PI * 0.75, Math.PI * (0.75 + (1.5 / totalStep * step)), false); // 可变圆弧
let gradient = canvasCtx.createLinearGradient(0, 0, 170, 0);
gradient.addColorStop(0, "#ED6F23");
gradient.addColorStop(0.5, "#E8ED2C");
gradient.addColorStop(1.0, "#58ED0C");
canvasCtx.strokeStyle = gradient;
});
}
<canvas id="myCanvas" type="2d" style="width: 300px; height: 150px;">
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
不随页面滚动是什么意思?
楼主这个问题现在解决了吗?
看一下你的定位样式
html:<canvas id="myCanvas" type="2d" style="width: 300px; height: 150px;"></canvas>
draw(step, totalStep) {
const query = mpvue.createSelectorQuery();
query.select("#myCanvas")
.fields({ node: true, size: true })
.exec((res) => {
const canvasObj = res[0].node;
const canvasCtx = canvasObj.getContext("2d");
canvasCtx.clearRect(0, 0, 600, 600);
canvasCtx.beginPath();
canvasCtx.arc(mpvue.getSystemInfoSync().windowWidth / 2, 80, 70, Math.PI * 0.75, Math.PI * 2.25, false); // 绘制外侧圆弧
canvasCtx.strokeStyle = "#ededed";
canvasCtx.lineCap = "round";
canvasCtx.lineWidth = 10;
canvasCtx.stroke();
canvasCtx.beginPath();
canvasCtx.arc(mpvue.getSystemInfoSync().windowWidth / 2, 80, 70, Math.PI * 0.75, Math.PI * (0.75 + (1.5 / totalStep * step)), false); // 可变圆弧
let gradient = canvasCtx.createLinearGradient(0, 0, 170, 0);
gradient.addColorStop(0, "#ED6F23");
gradient.addColorStop(0.5, "#E8ED2C");
gradient.addColorStop(1.0, "#58ED0C");
canvasCtx.strokeStyle = gradient;
canvasCtx.lineCap = "round";
canvasCtx.lineWidth = 10;
canvasCtx.stroke();
});
}
<canvas id="myCanvas" type="2d" style="width: 300px; height: 150px;">