1 回答
TA贡献1848条经验 获得超6个赞
您可以在这里看到timmywil panzoom库的简单实现,您可以轻松地使用道具和插槽来创建自己的组件,可在所有项目中重复使用
<template>
<div>
<div class="command">
<button @click="zoom(1)">ZoomIn</button>
<button @click="zoom(-1)">ZoomOut</button>
</div>
<div style="overflow: hidden;">
<div id="panzoom-element">
<img src="https://picsum.photos/300">
</div>
</div>
</div>
</template>
<script>
import Panzoom from '@panzoom/panzoom'
export default {
props: {
options: {type: Object, default: () => {}},
},
mounted() {
this.panzoom = Panzoom(document.getElementById('panzoom-element'), {
maxScale: 5
})
},
methods : {
zoom(level){
level === -1 ? this.panzoom.zoomOut() : this.panzoom.zoomIn()
}
}
}
添加回答
举报