vue2 can't use vue-email-editor

Viewed 30

I refer to the official website for installing vue-email-editor

unlayer vue-email-editor component link

and get this error

vue.runtime.esm.js?c320:4573 [Vue warn]: Error in render: "TypeError: (0 , external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.openBlock) is not a function"

TypeError: (0 , external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.openBlock) is not a function at Proxy.EmailEditorvue_type_template_id_eb864766_scoped_true_render (vue-email-editor.common.js?8479:21986:1)

Uncaught Error: Could not find a valid element for given id or className.

how should i do? thanks if there is any solution!

update:

after npm install vue-email-editor --save

app.vue:

<template>
  <div id="app">
    <h2>unlayer</h2>
    <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 ref="emailEditor" v-on:load="editorLoaded" />
    </div>
  </div>
</template>

<script>
import { EmailEditor } from 'vue-email-editor';
import sample from './data/sample.json';

export default ({
  components: {
    EmailEditor,
  },
  data() {
    return {
    };
  },
  methods: {
    editorLoaded() {
      // Pass your template JSON here
      // this.$refs.emailEditor.editor.loadDesign({});
      console.log('editorLoaded');
      this.$refs.emailEditor.editor.loadDesign(sample);
    },
    saveDesign() {
      this.$refs.emailEditor.editor.saveDesign(
        (design) => {
          console.log('saveDesign', design);
        },
      );
    },
    exportHtml() {
      this.$refs.emailEditor.editor.exportHtml(
        (data) => {
          console.log('exportHtml', data);
        },
      );
    },
  },
});
</script>

<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;}
</style>

update2:

i change install vue-email-editor from @2.0.0 to @0.7.2 then solve the problem but i don't know what's wrong with the newest version

0 Answers
Related