在solid中使用struct内的数组

问题描述 投票:0回答:1

我有一个如下结构:

struct Document {
    address[] haveAccess;
}

mapping(uint => Document) public documents;
address[] public arr;

 constructor() {
    documentsCount++;
    documents[documentsCount] = Document(arr);
 }

从truffle编译后从web3 js访问不会返回地址数组hasAccess。甚至不返回空数组。 web3调用是这样的

instance.documents(0).then(document=>{
    //dosomething with document
});

我需要数组有访问权限。

solidity web3js
1个回答
0
投票

尝试使用括号而不是括号进行调用。而且你还需要添加.call。看看here

© www.soinside.com 2019 - 2024. All rights reserved.