CleanId函数无法与MJML代码兼容
问题
即使在最新版本的 grapesjs(0.16.41)上,CleanID 仍然无法支持 MJML 代码。
这和这个已关闭的问题有关:https://github.com/artf/grapesjs/issues/3276
htmlOpts.attributes = (mod, attrs) => {
const { id } = attrs;
console.log(attrs) // 这日志在HTML dom上运行良好,但在MJML中不行,我也不知道为什么
如果(
ID &&
id[0] === 'i' &&
!mod.get('script') &&
!mod.get('attributes').id &&
idRules.indexOf(id) < 0
) {
删除 attrs.id;
}
退货;
};
这个函数不会读取MJML标签:“attrs”是空的,我找不到原因......
回答(2)
id 问题应该已经在最新的 mjml 插件版本中解决了
谢谢你举报,@ThomasPof。 关于CleanId函数无法与MJML代码配合提出的好问题。GrapesJS 推荐的方法是使用事件驱动 API。 从这里开始: 查看你所在模块的[GrapesJS文档](https://grapesjs.com/docs/) 寻找“on()”事件监听器方法 大多数操作可以通过监听编辑器和组件事件来实现 常见模式: “JavaScript 留意变化 editor.on('change', () => console.log('something changed')); 组件生命周期 editor.on('component:mount', (c) => con...
相关问答
通过相似的问题讨论继续研究。
问题 #3276
CleanId函数无法与MJML代码兼容
这个问题是关于 MJML 代码的,但我觉得这更多是关于 grapesjs 而不是 grapesjs-mjml 有一个函数可以移除“src/code_manager/model/HtmlGenerator.js”中不必要的ID。这个函数在 HTML 标签上表现良好,但在 MJML...
问题 #3142
AssetManager 渲染问题
@artf这正是之前已经被解决过的[问题#2760](https://github.com/artf/grapesjs/issues/2760),这是错了还是我做错了?我本以为资源不会显示出来,但它们全都可见 ![图片](https://user-images.githubus...
问题 #3367
模态模板
有没有办法修改已编译状态的模板? https://github.com/artf/grapesjs/blob/d3256e621bb43a537213ffcd86b10dc0bd070c0b/src/modal_dialog/view/ModalView.js#L1-L16 如...
问题 #3395
观察 -:移动视图不一致
你好@artf请观看附带的视频。 我检查过移动视图,发现移动视图和编辑移动视图不同。 大家有什么看法吗? 或者说,应该是这样工作 [屏幕录制 2021-04-09 2:55.45 PM.zip](https://github.com/artf/grapesjs/files/62...
与此问题匹配的付费插件
根据问题关键词和标签相关性精选,助你更快交付。
正在加载付费插件推荐……
相关教程
关于同一主题的深入指南。
教程
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
教程
PageKit: the GrapesJS application you'd have to build anyway
A source-available Next.js app around the open-source GrapesJS core — publishing, custom domains, leads, checkout and a plugin loader.
浏览插件分类
直接跳转到市场上的插件分类页面。