网页点击Adopt按钮,拿到帐户列表为空
来源:7-1 DAPP运行-总结

鲁智深110
2019-04-27
console.log(resultAccounts),拿到的列表为空?代码也没有报错,测试了很多次。?
handleAdopt: function(event) {
//处理领养
event.preventDefault();
var petId = parseInt($(event.target).data('id'));
console.log(petId)
//只读属性,返回当前节点持有的帐户列表。
web3.eth.getAccounts(function (error, resultAccounts) {
console.log(resultAccounts)
var AdoptionInstance;
var account = resultAccounts[0];
App.contracts.Adoption.deployed().then(function (instance) {
AdoptionInstance = instance;
return AdoptionInstance.adopt(petId, {from: account});
}).then(function(result) {
return App.markAdopted();
}).catch(function (err) {
console.log(err.message);
});
})
}
设置如图中显示,应该没有问题。
写回答
2回答
-
鲁智深110
提问者
2019-04-28
有个隐私模式,一直以为是ip地址问题,找了一天的时间,解决了!!!
00 -
鲁智深110
提问者
2019-04-28
metamask可以和本地的ganche交互,代码不行
00
相似问题