网页点击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

//img.mukewang.com/szimg/5cc546ca0001bff104350727.jpg


有个隐私模式,一直以为是ip地址问题,找了一天的时间,解决了!!!

0
0

鲁智深110

提问者

2019-04-28

metamask可以和本地的ganche交互,代码不行

//img.mukewang.com/szimg/5cc531c30001d38918590589.jpg

0
0

区块链入门与去中心化应用实战,快速入门区块链技术

一门课搞懂区块链核心原理,快速入门去中心化Dapp开发

1259 学习 · 208 问题

查看课程