功能:insertAdjacentHTML('afterend', '<section></section>')Grapesjs 里有类似的 API 吗?
你可以这样做: “''js const cmp = editor.getSelected(); cmp.parent().append('<section>...</section>', { at: cmp.index() + 1 }); ```
阅读下方完整回答 ↓问题
有没有办法在选定组件后面用 grapesjs 添加新部分?
回答(2)
你可以这样做: “''js const cmp = editor.getSelected(); cmp.parent().append('<section>...</section>', { at: cmp.index() + 1 });
谢谢你举报,@iabhiyaan。 关于FEAT: insertAdjacentHTML('afterend', '<section></section>')的好问题。Grapesjs 里有类似的 API 吗?推荐的组件方法是使用事件驱动的API。 从这里开始: 查看你所在模块的[GrapesJS文档](https://grapesjs.com/docs/) 寻找“on()”事件监听器方法 大多数操作可以通过监听编辑器和组件事件来实现 常见模式: “JavaScript 留意变化 editor.on('change', () => console.log('something changed...
相关问答
通过相似的问题讨论继续研究。
问题 #4273
如何在页面加载时触发“导入模板(模态)”
你好, 请问,我需要关于如何在页面初始化时导入模板模态的逻辑...... 我用的是新闻通讯预设插件 我想实现的是什么?:让用户在页面加载后上传代码。 以下是我尝试过的逻辑, editor.on('load',(model, argument)=> { 开放模数AL const...
问题 #3683
如何设置组件无法删除

问题 #3422
我们如何从文本组件“在这里插入你的文本”中移除默认文本内容?
我想像占位符一样,移除文本组件中的默认文本。每次拖动文本组件时,我们都需要手动移除默认文本。
问题 #3189
ChangesCount 是递增的,但不应用任何更改
[double-click.pptx](https://github.com/artf/grapesjs/files/5705054/double-click.pptx) 有没有可能,当你只双击某个组件时,“changesCount”参数并没有被递增? 当你双击且没有任何更改时...
与此问题匹配的付费插件
根据问题关键词和标签相关性精选,助你更快交付。
正在加载付费插件推荐……
相关教程
关于同一主题的深入指南。
教程
Vanilla GrapesJS vs GrapesJS With Plugins: What You Actually Get Out of the Box (2026)
New to GrapesJS? See exactly what the stock editor gives you, where it falls short, and which plugins close the gaps — a beginner-friendly 2026 comparison
教程
Lighthouse for GrapesJS: Audit Accessibility and SEO Without Leaving the Editor
Live WCAG 2.1/2.2 accessibility auditor + SEO manager for GrapesJS. Every finding is bound to the exact component — click to select, then one-click fix.
教程
GrapesJS DevTools: A Developer Panel Inside Your Editor
If you've ever debugged GrapesJS with console.log(editor.getSelected()) and a dozen throwaway event listeners — this post is for you.
浏览插件分类
直接跳转到市场上的插件分类页面。