How To Use Vue-Zoomer In Vue.js

In this article, We will learn the how to use the vue-zommer in vue.js.

Vue-Zoomer:

  • Zoom the image or other thing with mouse or touch.

Step: 1 Create a new Vue project:

vue create vue-zoomer-demo

Step: 2 Install the require packages:

npm i vue-zoomer

Step: 3 Open main.js file and add the following in it:

import Vue from 'vue'
import App from './App.vue'
import VueZoomer from 'vue-zoomer'

Vue.use(VueZoomer);
Vue.config.productionTip = false

new Vue({
  render: h => h(App),
}).$mount('#app')

Step: 4 Open App.vue file and add the following in it:

<template>
  <div id="app">
    <h3>Vue-Zoomer</h3>
    <v-zoomer
      ref="zoomer"
      style="width: 500px; border: solid 1px silver;margin:auto;"
      :zoomed.sync="zoomed"
    >
      <img
        src="./assets/landscape-1.jpg"
        style="object-fit: contain; width: 100%; height: 100%;"
      />
    </v-zoomer>
  </div>
</template>

<script>

export default {
  name: "App",
  data() {
    return {
      zoomed: false,
    };
  },
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

Code in Action:

Submit a Comment

Your email address will not be published.

Subscribe

Select Categories