Home  >  Article  >  Web Front-end  >  How to operate swiper in vue

How to operate swiper in vue

php中世界最好的语言
php中世界最好的语言Original
2018-06-11 14:19:502979browse

This time I will show you how to use swiper in vue, and what are the precautions for using swiper in vue. The following is a practical case, let's take a look.

Introduction to Swiper

Swiper is often used to touch and slide content on mobile websites.

Swiper is a sliding special effects plug-in created purely with JavaScript, targeting mobile terminals such as mobile phones and tablets.

Swiper can achieve common effects such as touch screen focus image, touch screen Tab switching, touch screen multi-image switching, etc.

Swiper is open source, free, stable, simple to use, and powerful. It is an important choice for building mobile terminal websites!

Solve the problem of using the swiper plug-in in vue. After introducing the swiper plug-in, we found that it could not run normally.

This time we simulated removing the data from the background, and then bound the data in the swiper tag.

 
 

The key point is the use of mounted(). These methods need to be used in mounted(). mounted() is the vue life cycle hook. You can also understand it as when the instance is mounted to the DOM. Only then will the method be triggered.

Let’s take a look at the usage of swiper in vue

First passnpm i vue-awesome-swiper --save Download the plug-in in vue

Then introduce it into main.js

require('swiper/dist/css/swiper.css')
import VueAwesomeSwiper from 'vue-awesome-swiper'
Vue.use(VueAwesomeSwiper)

Then insert the code into the structure of the component you need to use

Then in the data Define the carousel chart

swiperOption: {
pagination: '.swiper-pagination',
paginationClickable: true,
autoplay: 2500,
autoplayDisableOnInteraction: false,
loop: false,
coverflow: {
  rotate: 30,
  stretch: 10,
  depth: 60,
  modifier: 2,
  slideShadows : true
  }
},

The coverflow at this time is the way to switch the carousel chart. Changing the properties can switch the carousel mode.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Vue makes component carousel switching effect

How to use operator overloading

The above is the detailed content of How to operate swiper in vue. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]