reactjs 调用变量内容

gojuced7  于 2023-05-06  发布在  React
关注(0)|答案(1)|浏览(78)

我正在使用一个名为BankingWidgetSummary的小部件
下面是一个用法示例:

<BankingWidgetSummary
    title="Withdraws"
    color="warning"
    percent={-0.5}
    total={938}
    chart={{
        series: [111, 136, 76, 108, 74, 54, 57, 84],
    }}
    />

但要使用的图表系列从一个变量

export const _bankingMovements = [
     {     
    id: _mock.id(1),     
    type: "Deposit",     
    series: 10,     
    },
    {    
    id: _mock.id(2),
    type: "Deposit", 
    series: 20, 
    }, 
    { 
    id: _mock.id(3), 
    type: "Withdraw", 
    series: 20, 
    }, 
    { 
    id: _mock.id(4), 
    type: "Deposit", 
    series: 30, 
    }, 
];

我是这样使用的,但显然有错误,我找不到

<BankingWidgetSummary
    title="Deposits"
    percent={2.6}
    total={765}
    chart={_bankingMovements}
/>
s5a0g9ez

s5a0g9ez1#

const [bank, setBank] = useState([]);
 
 let _bankingMovements = {
             id: [ _mock.id(1), _mock.id(2), _mock.id(3), _mock.id(4)],
             datasets: { type: "Deposit", series: [10,20,30,40] }
         }
 
  setBank( _bankingMovements)
 
 <BankingWidgetSummary
     title="Deposits"
     percent='2.6'
     total='765'
     chart={bank}
 />

相关问题