@移动端pdf添加手势
移动端项目pdf添加手势问题
最近新接手的Vue项目需要对pdf添加手势,简单做一下总结
1.npm install alloyfinger
2. main.js中添加:
//AlloyFinger手势插件
import AlloyFinger from ‘alloyfinger’
import AlloyFingerPlugin from ‘alloyfinger/vue/alloy_finger_vue’
Vue.use(AlloyFingerPlugin,{AlloyFinger})
3.在pdf组件中
pdf.vue添加:
data() {
return {
fileType: “pdf”, // 文件类型
pdfSrc: “”,
contractNumber: “”,
pdfRule: “”,
posX: 0,
posY: 0,
dis: 1
};
pinchHandler(evt) {
this.dis = evt.zoom > 1 ? evt.zoom : 1;
},
touchMoveHandler(evt) {
this.posX += evt.deltaX;
this.posY += evt.deltaY;
},
doubleTapHandler() {
this.posX = 0
this.posY = 0
this.dis = 1
}