docs(前端配置): 更新前端配置文档中的示例代码
添加DOMContentLoaded事件监听器的替代调用方式示例
This commit is contained in:
@@ -63,12 +63,23 @@ comments.updateConfig({ theme: 'dark' });
|
|||||||
```html
|
```html
|
||||||
<div id="comments"></div>
|
<div id="comments"></div>
|
||||||
<script src="https://cwd.js.org/cwd.js"></script>
|
<script src="https://cwd.js.org/cwd.js"></script>
|
||||||
|
|
||||||
|
<!-- 实例调用 -->
|
||||||
<script>
|
<script>
|
||||||
const comments = new CWDComments({
|
const comments = new CWDComments({
|
||||||
el: '#comments',
|
el: '#comments',
|
||||||
apiBaseUrl: 'https://your-api.example.com', // 换成你的 API 地址
|
apiBaseUrl: 'https://your-api.example.com', // 换成你的 API 地址
|
||||||
});
|
});
|
||||||
comments.mount();
|
comments.mount();
|
||||||
|
|
||||||
|
// 或者
|
||||||
|
// document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
// const comments = new window.CWDComments({
|
||||||
|
// el: '#comments',
|
||||||
|
// apiBaseUrl: 'https://your-api.example.com',
|
||||||
|
// });
|
||||||
|
// comments.mount();
|
||||||
|
// });
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user