以hook方式请求数据
//导入
import React, { useState, useEffect } from "react";
export default function Demo(){
// 定义数据初值
const [dataSource, setDataSource] = useState([]);
useEffect(() => {
const getData = async () => {
try {
const result = await getFiles(10);
setDataSource(tableResource);
} catch (e) {
console.log("e :>> ", e);
}
};
getData();
}, []);
}
以上