<rem />

On this page
Alpha
Beta
Test

Table of contents

testing
demo
2025-01-25
Summary

这是一个 React 应用示例,展示了如何使用 useEffect 钩子在组件加载时设置页面标题。代码包含全局样式导入,并通过 MyApp 组件包装应用程序,实现了页面标题的动态设置功能。

Alpha

import { useEffect } from 'react';
import '@/styles/global.css';

const MyApp = ({ pageProps }) => {
  useEffect(() => {
    document.title = 'hello world';
  }, []);
  return <Component {...pageProps} />;
};

export default MyApp;

Beta

import { useEffect } from 'react';
import '@/styles/global.css';

const MyApp = ({ pageProps }) => {
  useEffect(() => {
    document.title = 'hello world';
  }, []);
  return <Component {...pageProps} />;
};

export default MyApp;

Test

import { useEffect } from 'react';
import '@/styles/global.css';

const MyApp = ({ pageProps }) => {
  useEffect(() => {
    document.title = 'hello world';
  }, []);
  return <Component {...pageProps} />;
};

export default MyApp;