我需要从远程数据中设置材料表列的查找。我试过了,但它不起作用:
const [authors, setAuthors] = useState([]);
const [state, setState] = React.useState({
columns: [
{field: 'id', title: 'ID', editable: 'never'},
{field: 'title', title: 'Titolo'},
{
field: 'author_id',
title: 'Autore',
// lookup: {12: 'cesare pavese', 124: 'david mccomb', 3: 'stephen king'},
lookup: {authors},
}
]
});
useEffect(() => {
async function getAuthors() {
const result = await axios.get(AUTHORS_ALL);
setAuthors(result.data);
}
getAuthors();
}, []);
远程调用有效,但不设置查找。你知道是否可以做到吗?