此刻,我正在学习redux,现在我已经用UseState钩子创建了一个列表,然后我映射了该列表并将其显示给用户,之后添加了一个按钮调用一个将对象添加到redux存储的函数,事实是,每当我控制台记录保存的对象时,它们就会以“对象对象”的形式出现,我该如何使用“ store.name”这样的名称来添加它们,我该对象的名称属性?以及如何使它们像这样出现在控制台上:
df[2] = df[2].replace(['\#', '\$'],'', regex=True).str.split(',')
df = (df.explode(2)
.groupby([0, 2])[2].count()
.rename('Count')
.reset_index()
.pivot_table(index=0, columns=2, values='Count')
.fillna(0)
.astype(int)
.reset_index())
df
Out[45]:
2 0 goin it mary and are been boys catch catching ... on \
0 john 0 0 1 1 1 1 0 0 1 ... 0
1 mary 0 0 0 1 0 0 1 1 0 ... 1
2 tom 1 1 0 0 0 0 0 0 0 ... 0
2 the there tom tom up well with ya'll you
0 0 1 0 1 1 1 1 0 2
1 1 0 1 0 0 0 0 1 1
2 0 0 0 0 0 0 0 0 0
[3 rows x 31 columns]
这是我的代码: 那就是我的映射功能:
0:
name: Product01,
Price: 10$
这是我的buyProduct函数
{item.map(product=>
<div>
<h1>{product.name}</h1>
<h2>{product.Price}</h2>
<button onClick={()=>buyProduct(item)}>Buy</button>
</div>)}
这是我的redux订阅:
const buyProduct=(item)=>{
store.dispatch({type:"buy", payload: item})
}
答案 0 :(得分:1)
问题是您将对象连接为字符串,在控制台中查看对象的方式为:
console.log('Store is now: ', store.getState())
相似,但不进行串联,而是将单独的参数传递给console.log
,然后让浏览器为您完成串联。