0

I know there are a few questions similar to this but they did not work for me so I am posting this.

I am trying to add jsPlumb into my Nuxtjs/Vuejs application. I did the following steps:

  1. npm i jsplumb --save
  2. Create a Vuejs page and add the simple code:
<template>
  <client-only>
    <div id="canvas" />
  </client-only>
</template>

<script>
import { jsPlumb } from 'jsplumb'

export default {
  mounted () {
    if (process.client) {
      console.log('MOUNTED - 2')
      jsPlumb.ready(function () {
        console.log('MOUNTED - 3')
      })
    }
  }
}
</script>

I get the error:

ReferenceError
document is not defined

I tried many things which were mentioned but nothing seems to work.

kissu
  • 40,416
  • 14
  • 65
  • 133
BATMAN_2008
  • 2,788
  • 3
  • 31
  • 98
  • Does this answer your question? [How to fix navigator / window / document is undefined in Nuxt](https://stackoverflow.com/questions/67751476/how-to-fix-navigator-window-document-is-undefined-in-nuxt) – kissu Nov 02 '21 at 17:15
  • @kissu Thanks for your response. But I have tried that answer but it did not work for me. If you check my code its the same. – BATMAN_2008 Nov 02 '21 at 17:21
  • Some solutions here could also be useful: https://stackoverflow.com/a/69572014/8816585 I guess I tried it last time and it worked. – kissu Nov 02 '21 at 17:25
  • @kissu I tried everything but nothing seem to work for me. I have modified the code can you please check and let me know what am I doing wrong? I checked many answers and all seem to address the same but for some reason it does not work for me. – BATMAN_2008 Nov 02 '21 at 19:29

1 Answers1

0

Instead of using process.client I used the process.browser and it worked fine for me. Please refer the link: https://stackoverflow.com/a/69822954/7584240

BATMAN_2008
  • 2,788
  • 3
  • 31
  • 98