功能:insertAdjacentHTML('afterend', '<section></section>')Grapesjs 里有类似的 API 吗?
你可以这样做: “''js const cmp = editor.getSelected(); cmp.parent().append('<section>...</section>', { at: cmp.index() + 1 }); ```
阅读下方完整回答 ↓问题
Is there any way to add new section after the selected component using 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...
相关问答
通过相似的问题讨论继续研究。
问题 #3683
How to set the component cannot be deleted

问题 #4273
How to trigger the 'Import Template (modal)' on page load
你好, 请问,我需要关于如何在页面初始化时导入模板模态的逻辑...... 我用的是新闻通讯预设插件 我想实现的是什么?:让用户在页面加载后上传代码。 以下是我尝试过的逻辑, editor.on('load',(model, argument)=> { 开放模数AL const...
问题 #3422
我们如何从文本组件“在这里插入你的文本”中移除默认文本内容?
我想像占位符一样,移除文本组件中的默认文本。每次拖动文本组件时,我们都需要手动移除默认文本。
问题 #3189
ChangesCount is incremented, without changes applied
[double-click.pptx](https://github.com/artf/grapesjs/files/5705054/double-click.pptx) 有没有可能,当你只双击某个组件时,“changesCount”参数并没有被递增? 当你双击且没有任何更改时...
与此问题匹配的付费插件
根据问题关键词和标签相关性精选,助你更快交付。
正在加载付费插件推荐……
相关教程
关于同一主题的深入指南。
教程
Introducing Search on GJS.Market
GJS.Market now has one search across everything we publish — plugins, articles, community questions, guides, authors and services. Press ⌘K from any page.
教程
GJS.Market Is Now Available for India 🇮🇳
GJS.Market is expanding its global presence with a dedicated experience for developers, agencies, SaaS companies, and digital creators in India
教程
如何在2026年用 GrapesJS 构建AI驱动的页面构建器
我们构建GJSDocs的经验——从简单的AI文本生成到结构化、上下文感知的视觉编辑
浏览插件分类
直接跳转到市场上的插件分类页面。