1.0.0 • Published 5 years ago

@eyelly/vue-printer v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Vue-Printer

Vue-Printer is a simple vue component for partial printing on the browser

Installation

NPM

Install the npm package, register the component

import Vue from 'vue'
import Printer from '@eyelly/vue-printer'

Vue.component('Printer',Printer)

CDN

Include the source file

<script src="https://unpkg.com/@eyelly/vue-printer/dist"></script>

Register the component

Vue.component('Printer',Printer)

Usage & Example

In single-file components

<template>
  <div>
    <div ref="printContent"> this is content to print </div>
    <div> this is normal content </div>
    <Printer :content="content">
      <button>print</button>
    </Printer>
  </div>
</template>

<script>
  import Vue from 'vue'

  export default {
    computed: {
      content() {
        return {
          refs: this.$refs,
          refName: 'printContent'
        }
      }
    }
  }
</script>

<style>
</style>

In HTML

<!doctype html>
<html>

  <head>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/@eyelly/vue-printer/dist"></script>
  </head>

  <body>
    <div id="app">
      <div ref='printContent'> this is content to print </div>
      <div> this is normal content </div>
      <Printer :content="content">
        <button>print</button>
      </Printer>
    </div>
    <script>
      Vue.component('Printer', Printer)
      new Vue({
        el: '#app',
        computed: {
          content() {
            return {
              refs: this.$refs,
              refName: 'printContent'
            }
          }
        }
      })
    </script>
  </body>

</html>

API

PropertyDescriptionTypeDefault
contentcontent to be printed{refs:object,refName:string}-
shotcutenable browser printing shortcutbooleantrue
newWindowopen a new window to printbooleanfalse
titlethe title of the newly opened windowboolean-

License

MIT