如何将视频标签的原始字符设置为动态?
问题
你好@artf, 你好,我有 blockmanager 里的拖放视频标签和按钮,点击按钮后,我需要把 URL 改成 src。但不行,请指点我。 编辑。BlockManager.add(“html/video”, { 标签:<div> <img src=“../../../Images/SiteBuilder/video.svg”/> <div class=“my-label-block”>视频</div> ',</div> 分类:“界面控制”, 标签:“UI Controls”, id:“UI Controls”, 内容: '<video id=“video1” src=“../../../Images/Jotun/Media21-1.m4v”id=“TestVideo” 控件类型=“video/mp4”>', }); 按钮事件: VA URL = “../../test.mp4“; $(“#video1”).attr('src', URL); 没有应用,有没有其他设置方式告诉我。
回答(4)
我觉得我有类似的定制组件。也许这会有帮助
如果你只需要更新方块内容(例如,变更会应用到新的拖拽方块上),你可以这样做: “''js const 块 = 编辑器。BlockManager.get('html/video'); block.set('content', '<video ...>')
如果你需要在画布中更改组件,我建议你更详细地阅读 [组件](https://grapesjs.com/docs/modules/Components.html)
感谢@artf和stf1981的回复,实际上我会拖放多个生成随机数到ID属性的视频。在这种情况下,如何更新针对特定版本的选定视频?
我未能更新src。
感谢你报告,@san-123。 关于如何将视频标签的src设置为动态?的好问题。GrapesJS 推荐的方法是使用事件驱动 API。 从这里开始: 查看你所在模块的[GrapesJS文档](https://grapesjs.com/docs/) 寻找“on()”事件监听器方法 大多数操作可以通过监听编辑器和组件事件来实现 常见模式: “JavaScript 留意变化 editor.on('change', () => console.log('something changed')); 组件生命周期 editor.on('component:mount', (c) => console.lo...
相关问答
通过相似的问题讨论继续研究。
问题 #5388
运行无头模式时,编辑器返回不同的 HTML
葡萄JS版本 [X] 我确认使用最新版本的GrapesJS 你用的是什么浏览器? ChromeV117.0.5938.62 可复制演示链接 https://codesandbox.io/embed/quizzical-galileo-cqldjh?fontsize=14&hid...
问题 #3702
HTML头标签未添加到dom中
我正在使用 [grapesjs library][1] 来构建网页,我根据文档添加了一个自定义块 [这里][1],当我拖动块到 canvas 时,HTML 数据会被添加,但 '<head></head>' 标签是空的, 这是我的代码 function tempOnePlugin...
问题 #3355
优点:在图层面板元素中添加标题属性
你好@artf, 当我在图层面板中嵌套多个元素时,由于图层面板宽度不够大,有些元素名称会被截断,我知道自定义可调整大小面板可以解决,但大多数用例中添加标题属性就足够了。 ) 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.
浏览插件分类
直接跳转到市场上的插件分类页面。