krux / postscribe

Asynchronously write javascript, even with document.write.
MIT License
986 stars 157 forks source link

window is not defined in vue #414

Closed warrebuysse closed 7 years ago

warrebuysse commented 7 years ago
<template>
  <div ref="globalfooter">
    <div id="global-footer"></div>
  </div>
</template>

<script>

import postscribe from 'postscribe'

  export default {
    name: 'global-footer',
    mounted () {
      postscribe('#global-footer', '<script src="//widgets-dev.hbplus.be/widget/live/70f9c938e7d94f4796131909296812c4"><\/script>')
    }
  }
</script>

Trying to use postscribe inside a Vue component but I keep hitting into the same "window is not defined" issue. Are there any hands-on examples with vue and postscribe?

jnewman commented 7 years ago

I don't think so. I'm thinking you'll need to build an adapter if you need special functionality for vue

rwsabhishek commented 1 year ago

I am facing the same issue with react/next js image

So to resolve this for now, I have to edit the node module postscribe.js file and add following conditions in line 1335. image var work={}; if (typeof window !== "undefined") work = window.document.createElement('div'); Please help me as how can i resolve this issue. Or it will be helpful if you add this condition at your module. So i will use the latest version

jnewman commented 1 year ago

@rwsabhishek I'd open a new issue, this one's been closed for >5yrs (I'm no longer part of this project).

rwsabhishek commented 1 year ago

@rwsabhishek I'd open a new issue, this one's been closed for >5yrs (I'm no longer part of this project).

Hello @jnewman ,my only suggestion here is to add the window check condition to the postscribe.js file and launch the new module version. So i can install the package