javascript - 在我的情况下,我得到:app.js:1 Uncaught ReferenceError: require is not defined
问题描述
对于我的示例,我找不到任何解决方案。
应用程序.js:
const TronWeb = require("tronweb");
const tronWeb = new TronWeb({
fullHost: "https://api.shasta.trongrid.io"
});
const publicAddress = tronWeb.defaultAddress.base58
console.log(publicAddress);
索引.html:
<script src="tronweb.js"></script>
<script src="app.js"></script>
localhost/index.html 我得到了错误。 在终端节点 app.js 中使用“我想在页面 index.html 中显示并且是相同的方式。也许缺少库?我试图从 github 转移,但我总是遇到同样的错误。
解决方案
推荐阅读
- android - Cordova ':app:mergeDebugNativeLibs' 错误
- vba - 在 VBA 中打印 SELECT 查询的结果 | 微软访问
- regex - Hive Regex_replace 给出了无法编译正则表达式模式:错误
- reactjs - React,如何防止在拖动后执行单击事件?
- scala - 如何组合没有公共列的数据框?
- android - 实时排序firebase控制台面板
- python - 使用循环将文本添加到 tkinter
- javascript - 如何在创建另一个对象后阻止原型中覆盖的函数的参数
- node.js - AWS Amplify 模拟功能
- php - 如何从 Viva Wallet 获取 OAuth 2 访问令牌