31 lines
825 B
TypeScript
31 lines
825 B
TypeScript
import React, { useEffect } from 'react';
|
|
|
|
const TestPage2: React.FC = () => {
|
|
console.log('TestPage2组件被渲染了');
|
|
|
|
useEffect(() => {
|
|
console.log('TestPage2组件挂载了');
|
|
// 测试API调用
|
|
const testApi = async () => {
|
|
try {
|
|
console.log('开始测试API调用...');
|
|
const response = await fetch('/api/users');
|
|
console.log('响应状态:', response.status);
|
|
const data = await response.json();
|
|
console.log('API返回数据:', data);
|
|
} catch (error) {
|
|
console.error('API调用失败:', error);
|
|
}
|
|
};
|
|
testApi();
|
|
}, []);
|
|
|
|
return (
|
|
<div style={{ padding: 24 }}>
|
|
<h1>测试页面</h1>
|
|
<p>这是一个测试页面,用于检查console.log是否正常工作。</p>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default TestPage2; |