相关疑难解决方法(0)

导入web3到下一个js会报错

我正在使用 next js 和 Material ui 构建一个用于学习的演示 dapp。我已经安装了元掩码,到目前为止我只能设置一个“连接到钱包”按钮。

我陷入了必须导入 Web3 构造函数的困境。我的代码如下所示:

我的包 json 的屏幕截图

作为开发人员,我也下载了一些无用的东西,因为我认为他们可以解决问题,但他们没有。

这是我收到的错误:

错误

这是整个错误:

服务器错误 TypeError: 无法设置只有 getter 的 # 属性请求

生成页面时发生此错误。任何控制台日志都将显示在终端窗口中。调用堆栈文件:///C:/projects/BC/vending-machine/node_modules/abortcontroller-polyfill/dist/polyfill-patch-fetch.js (529:18) 文件:///C:/projects/BC/自动售货机/node_modules/abortcontroller-polyfill/dist/polyfill-patch-fetch.js (542:5) file:///C:/projects/BC/vending-machine/node_modules/abortcontroller-polyfill/dist/polyfill- patch-fetch.js (3:3) 对象。文件:///C:/projects/BC/vending-machine/node_modules/abortcontroller-polyfill/dist/polyfill-patch-fetch.js (4:3) Module._compile 节点:internal/modules/cjs/loader (1155 :14) Object.Module._extensions..js 节点:internal/modules/cjs/loader (1209:10) Module.load 节点:internal/modules/cjs/loader (1033:32) Function.Module._load 节点:internal /modules/cjs/loader (868:12) Module.require 节点:internal/modules/cjs/loader (1057:19) require 节点:internal/modules/cjs/helpers (103:18)

请我已经尝试了一切。我希望有人能给出答案。如果您需要更多信息或屏幕截图或代码或任何东西请告诉我。就使用 Web3 而言,我只是简单地尝试导入它。我什至无法在不出现这些错误的情况下导入该死的东西。

这是我导入 web3 的地方

import * as React from "react";
import AppBar from "@mui/material/AppBar";
import Box from "@mui/material/Box";
import Toolbar from "@mui/material/Toolbar";
import Typography …
Run Code Online (Sandbox Code Playgroud)

javascript node.js next.js web3js

5
推荐指数
1
解决办法
1767
查看次数

标签 统计

javascript ×1

next.js ×1

node.js ×1

web3js ×1