GithubHelp home page GithubHelp logo

eyelly-wu / vue-printer Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 11 KB

A simple vue component for partial printing on the browser

License: MIT License

JavaScript 60.00% Vue 24.29% HTML 12.42% TypeScript 3.28%
vue print printer vue-print vue-printer

vue-printer's Introduction

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

Property Description Type Default
content content to be printed {refs:object,refName:string} -
shotcut enable browser printing shortcut boolean true
newWindow open a new window to print boolean false
title the title of the newly opened window boolean -

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.