创建图片链接后图片没有调整大小
你通过做这个“selectedComponent.view.el['outerHTML']来实现组件的扁平化,因此你移除了它的所有属性。 阅读更多关于[组件](https://grapesjs.com/docs/modules/Components.html)的工作原理。
阅读下方完整回答 ↓问题
'''let selectedComponent = editor.getSelected(); 令 href = this.getHref(); 令title = this.title; let childHtml ='<a id=“${selectedComponent.ccid}” title=“${title}” href=“${href}” target=“_blank” class=“gjs-comp-selected”>${selectedComponent.view.el['outerHTML']}</a>'; const coll = selectedComponent.collection; const at = coll.indexOf(selectedComponent); coll.remove(selectedComponent); coll.add(childHtml, { at }); selectComponent.view.render();'''
回答(1)
你通过做这个“selectedComponent.view.el['outerHTML']来实现组件的扁平化,因此你移除了它的所有属性。 阅读更多关于[组件](https://grapesjs.com/docs/modules/Components.html)的工作原理。
相关问答
通过相似的问题讨论继续研究。
问题 #2305
Grapesjs 已选元素中的 Wrap 和 UnWrap 功能无法正常工作
if(data.component.get('tagName') === 'img') { const selectedComponent = editor.getSelected(); const href = this.getHref(); const childHtml...
问题 #4929
A tag inside button is removed
GrapesJS 版本[X] 我确认使用最新版本 GrapesJS你用的是什么浏览器? Chrome 最新动态可复制演示链接 https://codesandbox.io/s/interesting-bell-xntbtr描述一下那个虫子 如何复现这个漏洞?进入代码沙盒拖放自定...
问题 #3652
如果我把文本改成链接, Grapes 就不识别链接。
你好@artf  我刚接触 Grapes JavaScript...
问题 #419
在命令中添加新元素
命令:{ { id:“submenuitem”, run: function(editor, senderBtn){ const comp = editor.getSelected(); comp.view.el.querySelector('[data-js=submenu_...
与此问题匹配的付费插件
根据问题关键词和标签相关性精选,助你更快交付。
正在加载付费插件推荐……
浏览插件分类
直接跳转到市场上的插件分类页面。