javascript运行时错误 未定义-未处理的运行时错误

如何解决未处理的运行时错误 - TypeError:无法读取定义的属性“长度”(Nextjs)? 我在开发过程中遇到了未处理的运行时错误 - TypeError: Cannot read property "length" of undefined (Nextjs)。 如何解决问题?下面主要结合日常开发经验,给大家提供未处理的运行时错误的解决方案建议——TypeError: Unable to read undefined property "length" (Nextjs)。 我希望它可以帮助您解决未处理的运行时错误 - TypeError: Cannot read property 'length' of undefined (Nextjs) 任何灵感或帮助; 问题描述

我正在编写代码来接受二维码图像并将其解码为字符串。

这些图像将是 Nextjs 文件夹“public”中的静态文件。

在我的代码中javascript运行时错误 未定义,我已将图像转换为“imageData”。 我成功转换并获得了一个返回 Uint8ClampedArray 的“imageData”对象。

然后,我使用这个 npm 库制作了一个 javascript 二维码阅读器。

但是,不知怎的javascript运行时错误 未定义,它给了我这个错误。

未处理的运行时错误 TypeError:无法读取未定义的属性“长度

这是我的 localhost:3000 中显示的错误

javascript运行时错误 未定义-未处理的运行时错误

当我查看我的代码编辑器时。 我在第 372 行有突出显示。

不过,我觉得 .next 库中的第 372 行是我不应该做的事情。

这可能就是我的代码。

这是我的代码。

索引.js

import Head from 'next/head'
import styles from '../styles/Home.module.css'
import jsQR from 'jsqr'
import { useEffect } from 'react'
export default function Home() {
  useEffect(() => {
    const canvas = document.getElementById("canvas");
    const ctx = canvas.getcontext('2d');
    const width = 200;
    const height = 200;
    const image = new Image;
    var imageDataT
    image.src = './Test_QR_Coupon.png'
    image.onload = () => {
      ctx.drawImage(image,width,height);
      imageDataT = ctx.getImageData(0,200,200);
      console.log(imageDataT);
    }
    const code = jsQR(imageDataT,300,'dontInvert')
    console.log('Code:',code)
    if (code) {
      console.log("Found QR code",code);
    }
  })
  return (
    <div classname={styles.container}>
      
        Create Next App
        
      
      <main classname={styles.main}>
        
      
<footer classname={styles.footer}> Powered by{' '} sname={styles.logo} />
) }

尚未找到解决方案

目前还没有有效的方法来解决这个程序的问题。 小编正在努力寻找和整理!

如果您找到了好的解决方案,请将解决方案连同此链接一起发送给编辑。

编辑邮箱:dio#foxmail.com(将#改为@)

javascript运行时错误 未定义-未处理的运行时错误

如果您喜欢与他人分享编程技术和工作经验,欢迎加入后端之家官方交流群!

编程之家官方组1(满)

编程之家官方组2(已满)

编程之家官方3组(已满)

编程之家官方4组

编程之家官方5组(新增)

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悟空资源网 javascript javascript运行时错误 未定义-未处理的运行时错误 https://www.wkzy.net/game/198444.html

常见问题

相关文章

猜你喜欢
官方客服团队

为您解决烦忧 - 24小时在线 专业服务