dansmaculotte / vue-zendesk

Vue.js plugin for Zendesk Web Widget
MIT License
33 stars 19 forks source link

[Vue warn]: Error in mounted hook: "TypeError: window.zE is not a function" #23

Closed thomergil closed 3 years ago

thomergil commented 3 years ago

I get an immediate error when trying to call this.$zendesk.show(). I add it as follows:

Vue.use(Zendesk, {
  key: [...],
  disabled: false,
  hideOnLoad: true,
  settings: {
    webWidget: {
      color: {
        theme: '#78a300',
      },
    },
  },
});

And use it as follows:

//...
<script lang="ts">
import Vue from 'vue';

export default Vue.component('app-footer', {
  mounted() {
    this.$zendesk.show();
  },
});

Happy to supply more information, but maybe it's obvious what I am doing wrong. Thank you.

thomergil commented 3 years ago

I think I found the answer to my own question:

this.$zendesk.$on('loaded', () => {
  this.$zendesk.show();
});
ak-akimoto-peraichi commented 1 year ago

@thomergil My name is Hiroyuki, nice to meet you.

I am using nuxt-zendesk and this error was detected by sentry. Since nuxt-zendesk uses vue-zendesk, I assume it is a similar error.

The version we are using is below, is the fix for this one internalized?

// package-lock.json
"@dansmaculotte/nuxt-zendesk": {
      "version": "0.4.2",.
      "resolved": "https://registry.npmjs.org/@dansmaculotte/nuxt-zendesk/-/nuxt-zendesk-0.4.2.tgz",.
      "integrity": "sha512-4ilgq0x6TzvQBAOzEHzJXeb6zGQM2208ikDzbacCOY2A42H7VI9l1ml3AxT5e6ShXToB6WMcQ8SHRMlpWaSTmA==",
      "requires": {
        "@dansmaculotte/vue-zendesk":"^0.4.1"
      }
    },
    "@dansmaculotte/vue-zendesk": {
      "version": "0.4.4", }
      "resolved": "https://registry.npmjs.org/@dansmaculotte/vue-zendesk/-/vue-zendesk-0.4.4.tgz",.
      "integrity": "sha512-J1Q70y95QsVODpPtVkhw5Fk8TvJ/j9oHCoSyoJvUq0hg9fj5csB60nsXC4xYmfV+4WD/AT72oVr2rT3y8wp8gg=="
    },
rtouze commented 1 year ago

Hello Hiroyuki,

The issue described by @thomergil is due to a wrong initialization of Zendesk widget. I can have multiple causes. By the way, this plugin is compatible with Vue 2. I'm currently not able to make it compatible to vue 3 (I'm not using Zendesk anymore for the projects I work on).

ak-akimoto-peraichi commented 1 year ago

@rtouze Oh, right, my apologies. Thank you for confirming.