专长:在方块上添加点击事件
其实你可以利用块中的[custom render](https://grapesjs.com/docs/modules/Blocks.html#custom-render)来应用自定义DOM事件。 “''js blockManager.add('some-block-id', { // ...区块定义 render: ({ model, el }) => { el.addEventListener('click', () => { console.log(“块状”,型号) }) }, }); ```
阅读下方完整回答 ↓问题
“''js editor.on('block:click', (block) => { console.log(区块) })
或者有没有办法在块子里监听点击事件?
回答(3)
其实你可以利用块中的[custom render](https://grapesjs.com/docs/modules/Blocks.html#custom-render)来应用自定义DOM事件。 “''js blockManager.add('some-block-id', { // ...区块定义 render: ({ model, el }) => { el.addEventListener('click', () => { console.log(“块状”,型号) }) }, });
谢谢你举报,@iabhiyaan。 关于FEAT:在方块上添加点击事件,这个问题很棒。GrapesJS 推荐的方法是使用事件驱动 API。 从这里开始: 查看你所在模块的[GrapesJS文档](https://grapesjs.com/docs/) 寻找“on()”事件监听器方法 大多数操作可以通过监听编辑器和组件事件来实现 常见模式: “JavaScript 留意变化 editor.on('change', () => console.log('something changed')); 组件生命周期 editor.on('component:mount', (c) => console...
相关问答
通过相似的问题讨论继续研究。
问题 #5689
<> 在开头引入 editor.getHtml()
葡萄JS版本[X] 我确认使用最新版本的GrapesJS你用的是什么浏览器? Chrome 版本 121.0.6167.185(官方构建)(64 位)可复制演示链接 https://jsfiddle.net/ja50kzne/4/描述一下那个虫子 如何复现这个漏洞?我之前有个...
问题 #4273
如何在页面加载时触发“导入模板(模态)”
你好, 请问,我需要关于如何在页面初始化时导入模板模态的逻辑...... 我用的是新闻通讯预设插件 我想实现的是什么?:让用户在页面加载后上传代码。 以下是我尝试过的逻辑, editor.on('load',(model, argument)=> { 开放模数AL const...
问题 #4577
防止使用自定义插件发生事件
葡萄JS版本[X] 我确认使用最新版本的GrapesJS你用的是什么浏览器? Chrome最新可复制演示链接 没有演示描述一下那个虫子 我想阻止事件,但我做不到,我试过了 以及如何预防商店事件,请帮帮忙 “''js editor.off('asset:upload:error'...
问题 #3366
扩展预览命令
我正在尝试扩展“预览”命令。 我本以为下面的代码会运行正常的预览命令和控制台输出,但实际上只有控制台语句能运行。 我怎样才能保留原始预览代码? 以下内容对我来说还算有效,直到有人能指出我哪里出了问题。
与此问题匹配的付费插件
根据问题关键词和标签相关性精选,助你更快交付。
正在加载付费插件推荐……
相关教程
关于同一主题的深入指南。
教程
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.
教程
How to Build a Production GrapesJS Editor: The Complete Walkthrough of Brief, Preset, Plugins, and Services
A complete walkthrough of building a production GrapesJS editor: how to choose a preset, pick plugins, and scope setup services without burning a sprint.
教程
Big Updates: TinyMCE 8 and Placeholder 2.0 for GrapesJS
In May we shipped major updates to two of our most popular GrapesJS plugins — TinyMCE Inline Text Editor and Placeholder.
浏览插件分类
直接跳转到市场上的插件分类页面。