我有以下代码需要翻译:
我所面临的问题是在前端打印这些值。
我有以下代码:
import React, { Component } from 'react'; import factory from '../ethereum/factory';
import ads_list from './ads_list' class showAds extends Component { static async getInitialProps(){ let i; let a = []; const ad=await factory.methods.getAdress().call(); const unique_address = Array.from(new Set(ad)); for ( i = 0 ;i < unique_address.length;i++){ a[i] = await factory.methods.getClientData(unique_address[i]).call(); } console.log(a); return {a}; } render(){ return <div> <p>{}</p> </div>; } } export default showAds;
[
{
'0': 'www.google.com',
'1': 'Click here and enjoy searching',
'2': '17'
},
{
'0': 'www.gmail.com',
'1': 'PLease login here',
'2': '2'
}
{
'0': 'www.google.com',
'1': 'Click here and enjoy searching',
'2': '17'
},
{
'0': 'www.gmail.com',
'1': 'PLease login here',
'2': '2'
}
]
我所面临的问题是在前端打印这些值。
data => <pre>{JSON.stringify(data, null, 2)}</pre>
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify - Håken Lid"Result" : [ {'0': 'www.google.com'}, {'1': '点击这里,享受搜索的乐趣'}, {'2': '17'} ]
- Revansiddh