功能: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”参数并没有被递增? 当你双击且没有任何更改时...
与此问题匹配的付费插件
根据问题关键词和标签相关性精选,助你更快交付。
正在加载付费插件推荐……
相关教程
关于同一主题的深入指南。
教程
How to Build an AI-Powered Page Builder with GrapesJS in 2026
What we learned building GJSDocs — from simple AI text generation to structured, context-aware visual editing
教程
How Much Does It Cost to Build a SaaS Page Builder in 2026?
How much does it cost to build a SaaS page builder in 2026? Explore realistic development costs, timelines, features, and how using GrapesJS can reduce
教程
UnStudio for GrapesJS: 4 Plugins to Build Better Visual Editors
Meet UnStudio, a new GrapesJS plugin studio with four tools, safer and better editor: Command Palette, Responsive Pack, Autosave & Restore, and Autofill
浏览插件分类
直接跳转到市场上的插件分类页面。