无法连接到节点 http://localhost:8545 [英] Couldn't connect to node http://localhost:8545
问题描述
问题的屏幕截图:
我的系统目录中的 web3.min.js 路径!
Web3.min.js 从我浏览器的文件夹中加载
在 index.html 文件所在的同一文件夹中复制 web3.min.js.
添加的代码
节点信息!我面临以下两个问题:
无法加载资源:web3.min.js:1 net::ERR_CONNECTION_REFUSED
错误:无法连接到节点 http://localhost:8545.
我的 Index.html 文件是
<html lang="zh-cn"><头><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>文档</title><link rel="stylesheet" type="text/css" href="main.css">
<身体><div class="容器"><h1>Coursetro 讲师</h1><h2 id="教师"></h2><label for="name" class="col-lg-2 control-label">讲师姓名</label><input id="name" type="text"><label for="name" class="col-lg-2 control-label">讲师年龄</label><input id="age" type="text"><button id="button">更新讲师</button>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script><脚本>if (typeof web3 !== 'undefined') {web3 = new Web3(web3.currentProvider);} 别的 {//从 Web3.providers 设置你想要的提供者web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));}web3.eth.defaultAccount = web3.eth.accounts[0];var CoursetroContract = web3.eth.contract([{常数":假,输入":[{"name": "_fName",类型":字符串"},{姓名年龄",类型":uint256"}],"name": "setInstructor",输出":[],应付":假,"stateMutability": "不可支付",类型":功能"},{常数":真的,输入":[],"name": "getInstructor",输出":[{姓名": "",类型":字符串"},{姓名": "",类型":uint256"}],应付":假,"stateMutability": "视图",类型":功能"}]);var Coursetro=CoursetroContract.at('0x95712aa4ff464e56f76af55da6239a368c459ed4');控制台日志(Coursetro);