1.1.9 • Published 1 year ago

cafe-ofd v1.1.9

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Cafe-OFD

NPM Publish NPM version GitHub stars GitHub issues GitHub forks

Render OFD files on Vue pages using ofd.js.

  • 😊 Vue 2.0 + ofd.js, Thanks ofd.js!
  • 😂 Support for modern browsers (IE11);

Install

npm install cafe-ofd --save

Quick Start

import cafeOfd from 'cafe-ofd'
import 'cafe-ofd/package/index.css'
Vue.use(cafeOfd)

Example

Demo:http://demo.const.team/ofd/

ofd test file download:

Note: the use of print, need to cooperate with the print style.

<template>
  <cafe-ofd ref="ofd" :filePath="file" @on-success="load" @on-scroll="scroll">
    <div slot="header">
      <input type="file" ref="file" class="hidden" accept=".ofd" @change="fileChanged">
    </div>
    <div slot="footer">
      <button @click="plus">plus</button>
      <button @click="minus">minus</button>
      <button @click="pre" :disabled="currentNum <= 1">pre</button>
      <input type="number" :min="1" :max="pageNum" v-model.number="currentNum" @change="pageChange(currentNum)">
      <button @click="next" :disabled="currentNum >= pageNum">next</button>
      <button @click="print">print</button>
    </div>
  </cafe-ofd>
</template>

<script>
export default {
  name: 'app',
  components: {},
  data() {
    //这里存放数据
    return {
      currentNum: null,
      file: null,
      pageNum: null
    };
  },
  methods: {
    load(val) {
      this.pageNum = val;
    },
    fileChanged() {
      this.file = this.$refs.file.files[0];
    },
    plus() {
      this.$refs.ofd.scale(50);
    },
    minus() {
      this.$refs.ofd.scale(-50);
    },
    next() {
      this.$refs.ofd.nextPage();
    },
    pre() {
      this.$refs.ofd.prePage();
    },
    pageChange(val) {
      this.$refs.ofd.goToPage(val);
    },
    print() {
      this.$refs.ofd.printFile();
    },
    scroll(val) {
      this.currentNum = val;
    }
  }
};
</script>

<style>
* {
  margin: 0;
  padding: 0;
}
html,
body,
#app {
  width: 100%;
  height: 100%;
  overflow: hidden;
}
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}
@media print {
  html,
  body,
  #app {
    height: auto;
    overflow: auto;
  }
}
</style>

Attributes

AttributeDescriptionTypeAccepted ValuesDefault
filePathofd sourcestring
widthofd widthnumber900

Events

Event NameDescriptionParameters
on-successsuccess eventpage count, ofd Object
on-errorerror eventerror
on-scrollscroll eventcurrent page, ofd Object

Methods

MethodDescriptionParameters
scalescalesteps
prePagepre page
nextPagenext page
goToPagego to pagepage number
printFilePrint all ofd

Slot

nameDescription
headerheader slot
footerfooter slot
1.1.9

1 year ago

1.1.8

1 year ago

1.1.1

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago