Javascript 前端开发:为什么返回值不能在我的浏览器中正确显示?

Javascript 前端开发:为什么返回值不能在我的浏览器中正确显示?,javascript,html,solidity,Javascript,Html,Solidity,我正在学习如何用Solidity(编程语言)编写智能合约,现在正在开发前端 在Solidity中,getter函数是自动生成的 问题:我得到的最后两个值以我不期望的方式显示 在我的合同中,我有以下结构和阵列: struct Voter{ bool vote; address add; string justification; } struct Proposal{ string descrip; uint target_val;

我正在学习如何用Solidity(编程语言)编写智能合约,现在正在开发前端

在Solidity中,getter函数是自动生成的

问题:我得到的最后两个值以我不期望的方式显示

在我的合同中,我有以下结构和阵列:

  struct Voter{
     bool vote;
     address add;
     string justification;
 }

 struct Proposal{
     string descrip;
     uint target_val;
     bytes2 ID;
     address recipient;
     uint pro_exch_rate;
     Voter []  votes;             
 }

 Proposal [] public proposals;
在我的.js文件中,我有:

// input some libraries 

window.App = {
//something here 
// we set proposal ...

get_proposal_spec: function(){
var indx2 = parseInt(document.getElementById("indx2").value);
var spec1 = document.getElementById("spec1");
var spec2 = document.getElementById("spec2");
var spec3 = document.getElementById("spec3");
var spec4 = document.getElementById("spec4");
var spec5 = document.getElementById("spec5");


  MetaCo.deployed().then(function(instancez) {
    return instancez.proposals.call(indx2);
  }).then (function(val){
   spec1.innerHTML = val[0].valueOf();
   spec2.innerHTML = val[1].valueOf();
   spec3.innerHTML = val[2].valueOf();
   spec4.innerHTML = val[3].valueOf();
   spec5.innerHTML = val[4].valueOf();
   })  },  };
在我的HTML文件中,我有:

<h1>Get Proposal Spec</h1>
<br><label for="indx2">Proposal Index:</label><input type="text" 
id="indx2" placeholder="e.g., 95"></input>
<br><br><button  id="send6" onclick="App.get_proposal_spec()">Set 
Proposal</button>
<br>
<span style="padding-left:130px;"> Description:<span   id="spec1">
</span>
<br>
<span style="padding-left:130px;"> Funding Amount:<span   id="spec2">
</span>
<br>
<span style="padding-left:130px;"> Proposal ID:<span   id="spec3">
</span>
<br>
<span style="padding-left:130px;"> Recipient Address:<span  id="spec4">
</span>
 <br>
<span style="padding-left:130px;"> Exchange rate:<span  id="spec5">
</span>
在我的浏览器中正确显示,但值val[3]和val[4]显示不正确。我已经和一位律师核对了我的合同,它正确地显示了结果。所以,我认为我在前端开发中犯了一些错误

编辑:我希望看到如下地址:

0xdfad09da5e9232bcb0188073c29b1a2807371398
以及分别表示val[3]和val[4]的整数。但我看到:

0x0000000000000000000000000000000000000000 


您希望在val[3]和val[4]中看到什么?您实际看到了什么?我不知道坚固性,但如果您将
spec
元素存储在一个数组中,然后对其进行迭代,然后在
val
数组中的相应位置获取值,不是更好吗?@carver感谢您的评论,我现在编辑了这个问题。@ArthurG如果我正确理解了你的建议,我会回答“否”,因为数组应该有相同类型的值。但在这里,每个建议规范都有不同的类型,例如字符串、uint等。我意识到,如果我在结构中更改值的顺序,如下所示,我就不会再有问题了:struct proposal{地址收件人;uint pro_exch______________________________________________________________,你到底看到了什么?我不知道坚固性,但如果你将
spec
元素存储在一个数组中,然后迭代它,然后在
val
数组中的相应位置获取值,不是更好吗?@carver谢谢你的评论,我现在已经编辑了这个问题。@ArthurG如果我理解你的建议正确的话首先,我会回答“否”,因为数组应该有相同类型的值。但这里每个建议规范都有不同的类型,例如string、uint等。我意识到,如果我在结构中更改值的顺序,如下所示,我就不会再有问题了:struct proposal{地址收件人;uint pro_exch______________________________________
0x0000000000000000000000000000000000000000 
6.5117631359869006216275524134217285150984976593190912e+52.