7***@qq.com
7***@qq.com
  • 发布:2021-05-12 11:10
  • 更新:2023-04-24 09:38
  • 阅读:562

【报Bug】topWindow 放canvas 提示 TypeError: Cannot read property 'id' of undefined

分类:uni-app

产品分类: uniapp/H5

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: w7

HBuilderX类型: Alpha

HBuilderX版本号: 3.1.14

浏览器平台: Chrome

浏览器版本: 88.0.4324.190(正式版本) (64 位)

项目创建方式: HBuilderX

示例代码:

topWindow页面代码:
<canvas canvas-id="test_canvas" style="background-color: #ff0;width:100px;height:50px;"></canvas>
js代码

    mounted() {  
        setTimeout(() => {  
            let ctx = uni.createCanvasContext('test_canvas');  
            ctx.setFillStyle('red');  
            ctx.fillRect(0, 0, 20, 20);  
            ctx.restore();  

            ctx.draw(false,()=>{  
                console.log('topWindow绘画成功');  
            });  
        }, 1000);  
    },

page-index的页面代码:
<canvas canvas-id="test_page_canvas" style="background-color: #ff0;width:100px;height:50px;"></canvas>
js代码

    onReady() {  
        setTimeout(() => {  
            let ctx = uni.createCanvasContext('test_page_canvas');  
            ctx.setFillStyle('red');  
            ctx.fillRect(0, 0, 20, 20);  
            ctx.restore();  

            ctx.draw(false,()=>{  
                console.log('Page绘画成功');  
            });  
        }, 1000);  
    },

操作步骤:

只要topWindow放了canvas组件,刷新页面就会提示错误,删掉重新刷新页面就正常

预期结果:

想要topWindow可以正常使用canvas组件画图

实际结果:

报TypeError: Cannot read property 'id' of undefined错误,canvas组件api没有报错ctx.draw能正常回调,但是画布内容没有显示出来

bug描述:

只要topWindow放了canvas组件,就会提示错误信息,而且画图也没效果,删掉topWindow里的canvas重新刷新页面就不会报错,使用组件引入也是一样的问题

而mainWindow里页面上的canvas组件可以正常使用

2021-05-12 11:10 负责人:无 分享
已邀请:
2***@qq.com

2***@qq.com

你好,后来怎么解决的啊,我这边也遇到了

要回复问题请先登录注册