Reactjs 反应处理api参数未显示
这是我的专栏。Reactjs 反应处理api参数未显示,reactjs,api,parameters,Reactjs,Api,Parameters,这是我的专栏。 我需要api中包含客户id的href。我目前正在使用reactTable,一切正常。但当我查看控制台内部时,只有参数没有被处理。 谁能告诉我少了什么 const columns = [ { Header: '', accessor: 'links[0].href', filterable: false, sortable: false, Cell: ({params}) => <Button color="seco
我需要api中包含客户id的href。我目前正在使用reactTable,一切正常。但当我查看控制台内部时,只有参数没有被处理。 谁能告诉我少了什么
const columns = [
{
Header: '',
accessor: 'links[0].href',
filterable: false,
sortable: false,
Cell: ({params}) => <Button color="secondary" onClick={()=>deleteCustomer(params)}>Delete</Button>
}
];
const deleteCustomer = (params) => {
console.log(params)
};
const getCustomer = () => {
fetch('https://customerrest.herokuapp.com/api/customers')
.then(response => response.json())
.then(data => setCustomer(data.content))
.catch(err => console.error(err))
};
我不认为react表在Cell选项的回调中提供了“params”。尝试传递不带花括号的参数,然后选择所需的数据
Cell:(params)=>deleteCustomer(params)}>Delete
我不认为react表在Cell选项的回调中提供了“params”。尝试传递不带花括号的参数,然后选择所需的数据
Cell:(params)=>deleteCustomer(params)}>Delete
在onClick句柄函数中传递参数:
Cell: ({params}) => <Button color="secondary" onClick={(params)=>deleteCustomer(params)}>Delete</Button>
Cell:({params})=>deleteCustomer(params)}>Delete
在onClick句柄函数中传递参数:
Cell: ({params}) => <Button color="secondary" onClick={(params)=>deleteCustomer(params)}>Delete</Button>
Cell:({params})=>deleteCustomer(params)}>Delete