子页面的js示例
```
<script>
// 接收父页面的主题模式
window.addEventListener('message', function(event) {
if (event.data.themeMode) {
var theme = event.data.themeMode;
// 测试是否正确接受到theme-mode的值
// console.log('Received theme mode from parent:', theme);
applyTheme(theme);
}
});
// 定义一个函数来应用主题
function applyTheme(theme) {
var body = document.body;
if (theme === 'dark') {
body.classList.add("dark-mode");
document.getElementById("darkModeToggle").checked = true;
} else {
body.classList.remove("dark-mode");
document.getElementById("darkModeToggle").checked = false;
}
}
</script>
```
React Template
Basic Usages
# Runs the app in the development mode
npm start
# Builds the app for production to the `build` folder
npm run build
If you want to change the default server, please set REACT_APP_SERVER environment variables before build,
for example: REACT_APP_SERVER=http://your.domain.com.
Before you start editing, make sure your Actions on Save options have Optimize imports & Run Prettier enabled.