PageKit — 可自托管的 GrapesJS 建站工具,附完整源码。 获取抢先体验

问题 #2621💬 已回答提出于 2020年3月4日作者 yuzhva1 个反应

编辑。Panels.addPanel 重复按钮

快速解答作者 yuzhva❤ 1

关闭了问题,因为我找到了另一个解决方案: “JavaScript const panelCustom = editor.Panels.addPanel({ ID:“panelcustom”, EL:“.panelcustom” }); const panelCustomButtons = panelCustom.get('buttons'); panelCustomButtons.add(topBarButtonsCenter); ``` 但关于“编辑”的问题。Panels.addPanel({ buttons: [] });' 仍然存在 (=

阅读下方完整回答 ↓

问题

在创建自定义插件时,如果是“编辑器”。Panels.addPanel' 使用了 Inside 插件功能——按钮是重复的。

示例: https://jsfiddle.net/kncdah8b/

按钮不重复:

  • 使用单一“Panels.addButton”接口,同时单独循环按钮
  • 在编辑器后添加面板时,创建了“const editor = grapesjs.init({})”

目前,我正在用下一个方法来避免出现重复: “JavaScript function gjsPlugin(editor) { editor.on('load', () => { 编辑。Panels.addPanel({ ID:“自定义面板”, EL: '.custom-panel', 按钮:[ { ID:“PANEL_ACTION。摘录, 类名:'fa fa-code', 命令:“export-template”, attributes: { title: '查看代码' } } ] }); }); }

回答(3)

yuzhva• 2020年3月6日

关闭了问题,因为我找到了另一个解决方案: “JavaScript const panelCustom = editor.Panels.addPanel({ ID:“panelcustom”, EL:“.panelcustom” }); const panelCustomButtons = panelCustom.get('buttons'); panelCustomButtons.add(topBarButtonsCenter); ``` 但关于“编辑”的问题。Panels.addPanel({ buttons: [] });' 仍然存在 (=

artf• 2020年3月7日

感谢@YUzhva的报告和解决方案。我会试着去看看

hellocaio• 2020年6月25日

我也是,我也测试了文档里面板示例(入门),但总是出现重复按钮。@yuzhva方案有效,谢谢:)

相关问答

通过相似的问题讨论继续研究。

与此问题匹配的付费插件

根据问题关键词和标签相关性精选,助你更快交付。

查看全部插件

正在加载付费插件推荐……

免费方案

在以下平台查看开源 GrapesJS 插件: GitHub 或在我们的免费目录中快速搜索。

浏览免费插件 →
高级方案

高级插件提供支持、定期更新和生产就绪的功能——为你节省数天的集成工作。

浏览高级插件 →

浏览插件分类

直接跳转到市场上的插件分类页面。