class MyComponent extends React.Component {
componentDidMount() {
const enterTime = new Date(); // 获取进入页面的时间
console.log('进入页面时间:', enterTime);
}
render() {
return <div>My Component</div>;
}
}
class MyComponent extends React.Component {
componentDidMount() {
const loadTime = performance.now(); // 获取页面响应的时间
console.log('页面响应时间(毫秒):', loadTime);
}
render() {
return <div>My Component</div>;
}
}