WEB3版本不一样到处
问题描述:
我初始化从metamask ectension WEB3在反应这个way-WEB3版本不一样到处
componentDidMount() {
window.addEventListener('load', function() {
let web3 = window.web3
web3 = new Web3(web3.currentProvider);
console.log(web3.version)
})
}
以上的console.log给予版本1.0.0-beta.22
,但是当我打电话web3.version
其他功能里面的成分 -
handleChange = (e) => {
let web3 = window.web3
console.log(web3.version)
};
这里console.log(web3.version)
给我安装version 0.20.2
WEB3版本USI ng npm的版本是1.0.0-beta.22
。我猜0.20.2版本是以某种方式被metamask注入的。我想要使用版本1.0.0-beta.22
无处不在。我怎样才能做到这一点?
答
原来我犯了一个愚蠢的错误。解决方案 -
componentDidMount() {
window.addEventListener('load', function() {
let web3 = window.web3
window.web3 = new Web3(web3.currentProvider);
console.log(web3.version)
})
}