创建图片链接后图片没有调整大小
你通过做这个“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...
问题 #3652
葡萄 js 如果我把文本改成链接,它不会识别链接。
你好@artf  我刚接触 Grapes JavaScript...
问题 #419
在命令中添加新元素
命令:{ { id:“submenuitem”, run: function(editor, senderBtn){ const comp = editor.getSelected(); comp.view.el.querySelector('[data-js=submenu_...
问题 #2464
在绝对拖拽模式下替换组件的问题
我遇到了一个问题,要替换一个元件在相同位置(上/左),新元件总是被添加到顶部:0px / 左:0px; 我正在考虑类似这样的内容: “''js const selectedComponent = editor.getSelected(); const coll = select...
与此问题匹配的付费插件
根据问题关键词和标签相关性精选,助你更快交付。
正在加载付费插件推荐……
浏览插件分类
直接跳转到市场上的插件分类页面。