选项 1:NPM 包
安装
npm install mellowtel-elements
实现
import { MellowtelElements } from 'mellowtel-elements';
// 使用你的扩展 ID 和配置密钥进行初始化
const mellowtel = new MellowtelElements('your-extension-id', 'your-config-key');
// 创建元素
await mellowtel.createElement('opt-in-container', { type: 'opt-in' });
await mellowtel.createElement('opt-out-container', { type: 'opt-out' });
await mellowtel.createElement('settings-container', { type: 'settings' });
选项 2:CDN
HTML 设置
<!DOCTYPE html>
<html>
<head>
<title>MellowTel 元素示例</title>
</head>
<body>
<!-- 元素的容器 div -->
<div id="opt-in-container"></div>
<div id="opt-out-container"></div>
<div id="settings-container"></div>
<!-- 从 CDN 加载 -->
<script src="https://cdn.jsdelivr.net/npm/mellowtel-elements@latest/dist/index.global.js"></script>
<script>
// 初始化 MellowTel 元素
const mellowtel = new window.MellowtelElements.default('your-extension-id', 'your-config-key');
// 创建元素
mellowtel.createElement('opt-in-container', { type: 'opt-in' });
mellowtel.createElement('opt-out-container', { type: 'opt-out' });
mellowtel.createElement('settings-container', { type: 'settings' });
</script>
</body>
</html>