mycurelabs / vue-html-to-paper

Vue mixin for paper printing html elements.
MIT License
298 stars 101 forks source link

Attempted to assign to readonly property. #89

Closed photuris closed 3 years ago

photuris commented 3 years ago

I'm a complete noob with vue.js, and I don't do Javascript much. So, apologies for the stupidity.

The following code works just fine when I run it with npm run dev (webpack), but it breaks when I run it with a production setup with express.

When I run it with npm run build && NODE_ENV=production node server.js, I get the following error in inspector:

TypeError: Attempted to assign to readonly property.

<button
  type="button"
  class="btn btn-primary"
  v-on:click="print_thing"
>
  <b-icon icon="printer"></b-icon> Print
</button>

<div id="print_area">
  Print this stuff in here
</div>

......

<script>
export default {
  methods: {
    print_thing: function () {
      this.$htmlToPaper('print_area')   /** Error occurs here */
    }
  }
}
</script>

Any ideas? Thanks!

photuris commented 3 years ago

Ok, so I just saw ticket #66. I'm sorry! So I tried this, but it's not working for me, either.

So, I clearly need to get myself up-to-speed with Javascript stuff.

<button
  type="button"
  class="btn btn-primary"
  v-on:click="print_thing"
>
  <b-icon icon="printer"></b-icon> Print
</button>

<div id="print_area">
  Print this stuff in here
</div>

......

<script>
import { htmlToPaper } from 'vue-html-to-paper'

export default {
  methods: {
    print_thing: function () {
      htmlToPaper('print_area')   /** Error occurs here */
    }
  }
}
</script>
photuris commented 3 years ago

Just did it the old school way.