1.0.2 • Published 5 years ago

vue-pdf-syl v1.0.2

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

使用

npm install vue-pdf-syl --save
npm install pdfjs-dist --save

app.vue

<template>
    <div id="app">
        <vuePdf :height="pdfHeight" :pdfUrl="pdfUrl"></vuePdf>
    </div>
</template>

<script>
import vuePdf from 'vue-pdf-syl'

export default {
    name: 'app',
    components: {
        vuePdf
    },
    data () {
        return {
            pdfHeight: '500px',
            pdfUrl: 'static/test.pdf'
        }
    }
}
</script>
<style scoped>

</style>

注意

  • 接受后台传输的pdf,后台应该以流的形式进行传输,前端接收看下面代码
getPdfFun () {
  axios({
    method: 'get',
    url: url, // 后台传输pdf地址
    data: {},
    responseType: 'blob'
  }).then(res => {
    let url = window.URL.createObjectURL(new Blob([res.data]))
    this.pdfUrl = url
  })
}
1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago