-1

在我的角度应用程序中,我正在尝试dragMode这样使用绝对值

所以在我的component.ts中我添加了dragMode:

  grapesjs.init({
  container: '#gjs',
  autorender: true,
  forceClass: false,
  dragMode: 'absolute',
  components: '',
  style: '',

它给出了一个错误,说在拖动块时没有定义编辑器,我该如何解决这个问题,以及如何让特定的块具有绝对dragMode的 .

4

1 回答 1

1

Hack:如果编辑器在全球范围内可用,那么它就可以工作。就像将编辑器分配给 window.editor。我遇到了同样的问题。到目前为止,还没有解释为什么编辑器在绝对模式下是未定义的。

window.editor = this.editor;

我不确定这是否是最好的方法。

component.set('dmode', 'absolute'); 或者

editor.on("component:selected", function (model) {
  if (component.attributes.type === 'Your component type') {
    model.set('dmode', 'absolute');
 }
});
于 2020-02-28T08:25:12.103 回答