Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我运行示例项目的第三个demo,报错 "TypeError: Cannot set property 'width' of undefined" #34

Closed
letear opened this issue Mar 28, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@letear
Copy link

letear commented Mar 28, 2023

    const dp = createDrawPoster({
      selector: 'canvas',
    })
    dp.mount()
    console.log(dp.canvas) // undefined
    dp.canvas.width = 300
    dp.canvas.height = 300

    dp.draw((ctx) => {
      ctx.fillStyle = '#F4F4F4'
      ctx.fillRect(0, 0, 300, 300)
    })
    // 测试本地/网络地址
    const url = '/static/tabbar/wode.jpg' /* 网络图片 */
    // 测试案例一:绘制图片(矩形)
    dp.draw(async (ctx) => {
      await ctx.drawImage(url, 0, 150, 150, 150)
      await ctx.drawImage(url, 150, 150, 150, 150)
    })
    // 测试案例二:绘制图片(圆角)
    dp.draw(async (ctx) => {
      await ctx.drawRoundImage(url, 0, 0, 150, 150, 100)
      await ctx.drawRoundImage(url, 150, 0, 150, 150, 100)
    })
    // 创建本地地址
    this.imgUrl = await dp.create()
    console.log('创建地址:', { url: this.imgUrl })
  },
}
@letear
Copy link
Author

letear commented Mar 28, 2023

插件版本3.0.2

@hairyf hairyf added the bug Something isn't working label Mar 31, 2023
@hairyf hairyf closed this as completed Apr 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants