Vue如何实现图片的放大缩小功能?(代码介绍)

2024年06月16日 建站教程

<template>
  <div>
    <img :src="/staticimageSrc" v-bind:>
    <button @click="zoomIn">放大</button>
    <button @click="zoomOut">缩小</button>
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      scale: 1.0, //默认图片大小
      imageSrc: 'images/pic.jpg'
    };
  },
  methods: {
    //放大图片
    zoomIn() {
      this.scale += 0.1;
    },
	//缩小图片
    zoomOut() {
      this.scale -= 0.1;
    }
  }
};
</script>

本文链接:http://so.lmcjl.com/news/6684/

展开阅读全文
相关内容