Vuejs: 如何使用vue-email-editor?

huangapple go评论64阅读模式
英文:

Vuejs: How to use vue-email-editor?

问题

我试图将vue-email-editor集成到我的源代码中。我按照说明进行了操作,但仍然无法集成vue-email-editor。以下是我的操作步骤以及我遇到的错误:

步骤1:npm install vue-email-editor --save

步骤2:在App.vue

<template>
  <div id="app">
    <div class="container">
      <div id="bar">
        <h1>Vue Email Editor (Demo)</h1>

        <button v-on:click="saveDesign">Save Design</button>
        <button v-on:click="exportHtml">Export HTML</button>
      </div>

      <EmailEditor
        :appearance="appearance"
        :min-height="minHeight"
        :project-id="projectId"
        :locale="locale"
        :tools="tools"
        :options="options"
        ref="emailEditor"
        v-on:load="editorLoaded"
        v-on:ready="editorReady"
      />
    </div>
  </div>
</template>

<script>
  import { EmailEditor } from 'vue-email-editor';

  export default {
    name: 'app',
    components: {
      EmailEditor,
    },
    data() {
      return {
        minHeight: '1000px',
        locale: 'en',
        projectId: 0, // 替换为您的项目ID
        tools: {
          // 禁用图像工具
          image: {
            enabled: false,
          },
        },
        options: {},
        appearance: {
          theme: 'dark',
          panels: {
            tools: {
              dock: 'right',
            },
          },
        },
      };
    },
    methods: {
      // 编辑器创建时调用
      editorLoaded() {
        console.log('editorLoaded');
        // 在此处传递您的模板JSON
        // this.$refs.emailEditor.editor.loadDesign({});
      },
      // 编辑器加载完成后调用
      editorReady() {
        console.log('editorReady');
      },
      saveDesign() {
        this.$refs.emailEditor.editor.saveDesign((design) => {
          console.log('saveDesign', design);
        });
      },
      exportHtml() {
        this.$refs.emailEditor.editor.exportHtml((data) => {
          console.log('exportHtml', data);
        });
      },
    },
  };
</script>

然后我运行源代码并得到以下错误:

Uncaught TypeError: __webpack_modules__[moduleId] is not a function
    at __webpack_require__ (app.js?id=ee06f5f7860fd239b953:166893:41)
    at app.js?id=ee06f5f7860fd239b953:186888:68
    at app.js?id=ee06f5f7860fd239b953:187073:2
    at ./node_modules/vue-email-editor/dist/vue-email-editor.common.js (app.js?id=ee06f5f7860fd239b953:187075:12)
    at __webpack_require__ (app.js?id=ee06f5f7860fd239b953:64:30)
    at ./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./frontend/src/App.vue?vue&amp;type=script&amp;lang=js&amp; (app.js?id=ee06f5f7860fd239b953:117639:74)
    at __webpack_require__ (app.js?id=ee06f5f7860fd239b953:64:30)
    at ./frontend/src/App.vue?vue&amp;type=script&amp;lang=js&amp; (app.js?id=ee06f5f7860fd239b953:110481:194)
    at __webpack_require__ (app.js?id=ee06f5f7860fd239b953:64:30)
    at ./frontend/src/App.vue (app.js?id=ee06f5f7860fd239b953:110445:91)

参考链接: https://github.com/unlayer/vue-email-editor

我已经搜索了很多,但没有找到可以帮助我解决这个错误的解决方案。如果有人成功集成过,请给我提供解决上述错误的方法。谢谢。

英文:

I'm trying to integrate vue-email-editor into my source. I followed the instructions but still can't integrate vue-email-editor. And here is how I do it and the error I'm getting:

Step 1: npm install vue-email-editor --save

Step 2: In App.vue

&lt;template&gt;
&lt;div id=&quot;app&quot;&gt;
&lt;div class=&quot;container&quot;&gt;
&lt;div id=&quot;bar&quot;&gt;
&lt;h1&gt;Vue Email Editor (Demo)&lt;/h1&gt;
&lt;button v-on:click=&quot;saveDesign&quot;&gt;Save Design&lt;/button&gt;
&lt;button v-on:click=&quot;exportHtml&quot;&gt;Export HTML&lt;/button&gt;
&lt;/div&gt;
&lt;EmailEditor
:appearance=&quot;appearance&quot;
:min-height=&quot;minHeight&quot;
:project-id=&quot;projectId&quot;
:locale=&quot;locale&quot;
:tools=&quot;tools&quot;
:options=&quot;options&quot;
ref=&quot;emailEditor&quot;
v-on:load=&quot;editorLoaded&quot;
v-on:ready=&quot;editorReady&quot;
/&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/template&gt;
&lt;script&gt;
import { EmailEditor } from &#39;vue-email-editor&#39;;
export default {
name: &#39;app&#39;,
components: {
EmailEditor,
},
data() {
return {
minHeight: &#39;1000px&#39;,
locale: &#39;en&#39;,
projectId: 0, // replace with your project id
tools: {
// disable image tool
image: {
enabled: false,
},
},
options: {},
appearance: {
theme: &#39;dark&#39;,
panels: {
tools: {
dock: &#39;right&#39;,
},
},
},
};
},
methods: {
// called when the editor is created
editorLoaded() {
console.log(&#39;editorLoaded&#39;);
// Pass your template JSON here
// this.$refs.emailEditor.editor.loadDesign({});
},
// called when the editor has finished loading
editorReady() {
console.log(&#39;editorReady&#39;);
},
saveDesign() {
this.$refs.emailEditor.editor.saveDesign((design) =&gt; {
console.log(&#39;saveDesign&#39;, design);
});
},
exportHtml() {
this.$refs.emailEditor.editor.exportHtml((data) =&gt; {
console.log(&#39;exportHtml&#39;, data);
});
},
},
};
&lt;/script&gt;

And then I run source and get the error:

Uncaught TypeError: __webpack_modules__[moduleId] is not a function
at __webpack_require__ (app.js?id=ee06f5f7860fd239b953:166893:41)
at app.js?id=ee06f5f7860fd239b953:186888:68
at app.js?id=ee06f5f7860fd239b953:187073:2
at ./node_modules/vue-email-editor/dist/vue-email-editor.common.js (app.js?id=ee06f5f7860fd239b953:187075:12)
at __webpack_require__ (app.js?id=ee06f5f7860fd239b953:64:30)
at ./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./frontend/src/App.vue?vue&amp;type=script&amp;lang=js&amp; (app.js?id=ee06f5f7860fd239b953:117639:74)
at __webpack_require__ (app.js?id=ee06f5f7860fd239b953:64:30)
at ./frontend/src/App.vue?vue&amp;type=script&amp;lang=js&amp; (app.js?id=ee06f5f7860fd239b953:110481:194)
at __webpack_require__ (app.js?id=ee06f5f7860fd239b953:64:30)
at ./frontend/src/App.vue (app.js?id=ee06f5f7860fd239b953:110445:91)

Reference links : https://github.com/unlayer/vue-email-editor

I have searched a lot but there is not a solution that helps me to fix this error. If anyone has successfully integrated, please give me a solution to fix the above error. Thanks.

答案1

得分: 1

这个问题也在这里报告了,并且建议将版本降级到1.0.0以使其可用。

这是带有1.0.0版本的vue-email-editorcodesandbox演示

(我无法创建代码段,因为此库的CDN不可用。)

英文:

This issue is also reported here, and it says to downgrade the version to 1.0.0 to make it workable.

Here is the codesandbox demo of vue-email-editor with version 1.0.0.

(I could not create snippet because CDN of this library is not available.)

huangapple
  • 本文由 发表于 2023年1月9日 11:47:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75053003.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定