脚本道具无效
这里似乎一切正常:https://jsfiddle.net/rp7wa58h/ 无论如何,如果你不用“视图”,其实也不需要它,“isComponent”(在你的示例中拼写错误且位置错误)也是一样,“data-gjs-type”默认已被编辑器自动使用。
阅读下方完整回答 ↓问题
你好!@artf,感谢你的精彩工作! 我选择值时会跟着 https://grapesjs.com/docs/modules/Components-js.html#passing-properties-to-scripts,but 操作,脚本没有执行,期待大家的建议,非常感谢! “''javascript export default function(editor, opt = {}) { cont c = opt; const domc = 编辑。主导组件; const defaultType = domc.getType(“default”); const defaultView = defaultType.view; cont TYPE = “测试”; const script = function (props) { alert(“嗨”); }; 编辑。Components.addType(TYPE, { 型号:{ 默认值:{ 脚本, 标题:“value1”, '剧本道具': [''标题'], 特质:[ { 类型:“选择”, 名称:“Stitle”, changeProp:true, 选项:[ { value:“value1”, name:“value 1” }, { value: “value2”, name: “Value 2” }, ], }, ], }, Comp...
回答(2)
这里似乎一切正常:https://jsfiddle.net/rp7wa58h/ 无论如何,如果你不用“视图”,其实也不需要它,“isComponent”(在你的示例中拼写错误且位置错误)也是一样,“data-gjs-type”默认已被编辑器自动使用。
感谢你在2016年@momu报告此事。
感谢你分享关于剧本道具无效的报告。为了帮助团队调查并优先排序:
请提供:
- 一个最小可复现的例子(CodeSandbox/JSFiddle)
- 你的GrapesJS版本号
- 浏览器和操作系统信息
- 浏览器控制台的任何错误信息
- 重现问题的步骤
最有帮助的是什么:
- 简约代码示例(不是你整个项目)
- 屏幕录制或截图显示问题
- 明确区分预期行为与实际行为
- 你正在使用的GrapesJS配置
有了这些细节,维护者可以更快地识别和优先排序修复。GrapesJS团队对有充分记录的问题反应迅速。
相关问答
通过相似的问题讨论继续研究。
问题 #3316
编辑器不会移除死稿块
版本: 0.16.34 你能重现演示中的bug吗? [ ] 是的 [x ] 不 据我了解,导入代码对话框跳过了所有HTML脚本,所以我无法在演示中重现这个问题 预期的行为是什么? 编辑者必须先移除失效脚本块,才能在生成的HTML末尾添加新的脚本块 详细描述那个漏洞* 我在项目中...
问题 #3688
如何自定义组件
我 https://grapesjs.com/docs/modules/Components.html#define-custom-component-type 读了这份文档,并尝试编写以下代码。我想让“mj-body”无法删除: 但我看不到效果,请帮帮我
问题 #3258
防止/禁用自定义块被丢弃在其他自定义块中
你好, 我有一个自定义组件,我们称它为Section Block。我想防止用户在其他区块里丢弃分段块。这可能吗? 参考:https://grapesjs.com/docs/modules/Components.html#define-custom-component-type...
问题 #5768
BlockProperties 中“content”属性的类型错误
葡萄JS版本 [X] 我确认使用最新版本的GrapesJS 你用的是什么浏览器? Chrome v122 可复制演示链接 不适用 描述一下那个虫子 GrapeJs 文档表明,可以在块的“content”属性中添加混合内容(见 https://grapesjs.com/docs/...
与此问题匹配的付费插件
根据问题关键词和标签相关性精选,助你更快交付。
正在加载付费插件推荐……
相关教程
关于同一主题的深入指南。
教程
Vanilla GrapesJS vs GrapesJS With Plugins: What You Actually Get Out of the Box (2026)
New to GrapesJS? See exactly what the stock editor gives you, where it falls short, and which plugins close the gaps — a beginner-friendly 2026 comparison
教程
Lighthouse for GrapesJS: Audit Accessibility and SEO Without Leaving the Editor
Live WCAG 2.1/2.2 accessibility auditor + SEO manager for GrapesJS. Every finding is bound to the exact component — click to select, then one-click fix.
教程
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.
浏览插件分类
直接跳转到市场上的插件分类页面。