// x-card.js —— 插槽 + Shadow DOM 样式隔离 export class XCard extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }).innerHTML = `
默认标题

shadow 内部的 p(红色)

`; } } if (typeof customElements !== 'undefined' && !customElements.get('x-card')) { customElements.define('x-card', XCard); }