Modern.js
Get started by editing src/routes/page.tsx
import { Helmet } from '@modern-js/runtime/head'; import './index.css'; import { appendElement, appendLinkTag, appendScriptTag, appendStyleTag, createElement, } from '@module-federation/side-effect-pkg'; import React from 'react'; // @ts-ignore window.kkk = 3; // 使用 append 方法直接添加元素到 DOM appendLinkTag( 'https://lf3-static.bytednsdoc.com/obj/eden-cn/upspbovhj/edenx-ico.icocccc', document.head, 'icon', 'image/x-icon', ); appendStyleTag( `body { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }`, document.head, ); // 添加一个实际的脚本标签 appendScriptTag( undefined, document.body, `console.log('Side effect script executed!');`, 'text/javascript', false, false, ); // 创建一个容器并添加到页面 const container = createElement('div', { className: 'dynamic-container', style: 'padding: 20px; border: 2px solid #ccc; margin: 10px; border-radius: 8px;', }); container.textContent = 'This is a dynamically created container!'; appendElement(container, document.body); const Index = () => (
Modern.js
Get started by editing src/routes/page.tsx