canvas组件在pc上不支持吗?

小程序 文章 2021-03-26 15:42 378 0 全屏看文

AI助手支持GPT4.0

canvas组件在pc上不支持吗?Is the canvas component not supported on the pc?

canvas组件在pc上不支持吗?
Page({  onReady() {    const query = wx.createSelectorQuery()    query.select('#canvas')      .fields({ nodetruesizetrue })      .exec((res) => {        const canvas = res[0].node        const ctx = canvas.getContext('2d')        const dpr = wx.getSystemInfoSync().pixelRatio        canvas.width = res[0].width * dpr        canvas.height = res[0].height * dpr        ctx.scale(dpr, dpr)        ctx.fillRect(00100100)      })  }})直接用了文档上的代码,在pc小程序上没有效果。res[0].node 为nullpc不支持canvas吗?

Page({  onReady() {    const query =  wx.createSelectorQuery ()     query.select ('#canvas')      .fields({ node: true,  size: true })      .exec((res) => {        const canvas = res[0].node        const ctx =  canvas.getContext ('2d')        const dpr =  wx.getSystemInfoSync ().pixelRatio         canvas.width  = res[0].width * dpr         canvas.height  = res[0].height * dpr         ctx.scale (dpr,  dpr)         ctx.fillRect (0, 0, 100, 100)}) directly uses the code in the document, which has no effect on the PC small program. Res [0]. Node nullpc does not support canvas?

回答:

社区技术运营专员-壹君:

目前暂不支持pc端

happy欢乐🐷:

应该说是canvas2d,pc上无法获取node

😮😮:不支持 :)
😮😮:pc上不支持 2d
happy欢乐🐷:嗯 ,好郁闷
😮😮:可以使用普通的canvas 但是已经不维护了。自己看着办吧
黑夜白昼1999:

不知道为什么,重来没在PC上成功打开过小程序

😮😮:我pc上打开的只不过比较慢 :)
黑夜白昼1999:点击小程序后,指针旁出现O加载圆圈,一会O就消失了。一切恢复如初,就像你 没有点击过小程序一样

-EOF-

AI助手支持GPT4.0