:对于使用脚本函数(非字符串)的组件使用shim 函数
目前将组件脚本转换为文本再放入文档的方法相当受限。难道不能采用这样的方法,从而保留范围吗? 把函数放在 Windows 里,然后在组件里用垫片函数。 original代码: “''js var myVar = “约翰”; 编辑。BlockManager.add('test-block', { ... 脚本:函数 () { alert('Hi' + myVar); console.log(“元素”,此词); }, ... }); globalThis['test-block'] = identifierOfTheTestBlockComponent.script 最初在公关中提及,这里 https://github.com/artf...
artf
难道不能采用这样的方法,从而保留范围吗? 不,因为你试图将编辑器环境的范围和最终用户部署的范围混合在一起(这和编辑器无关,他只能看到最终的HTML/CSS/JS)。 试着看看这个问题:https://github.com/artf/grapesjs/issues/2181