Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What problems will swiper encounter in vue?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

The purpose of this article is to share with you about what problems swiper will encounter in vue. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Example: error (unable to display the pager button, this function is not applicable to pictures looped out by for, but can only be used when several pictures are fixed on this page)

Step 1: install npm i swiper (included with the vue plug-in)

Step 2: introduce into the current page

Import Swiper from 'swiper';import' swiper/dist/css/swiper.min.css'

Step 3: of course, maybe you are thinking about the content. Don't worry. I will also provide you with the writing of the content for your convenience.

(for loop) (tip: you can replace the for loop with a normal display of pictures, as shown below. The pager corresponding to each picture is put in, and the pager can be used. The pager like the for loop cannot be displayed and switched.)

< !--

-- > (of course, you can also add several optional div,img paths according to the data in the above for loop, and they will not be displayed. The pager displays and switches the rotation according to the judgment of the swiper-slide) (pager)

Add this method to the vue initialization request

Mounted () {var that = this That.$nextTick (function () {var mySwiper = new Swiper (".swiper-container", {direction: "horizontal", / * horizontal slide * / loop:true) to form a loop (that is, you can jump from the last picture to the first picture pagination: ".swiper-pagination" / * pager * / autoplay:3000/* automatically plays every 3 seconds * /}) })}

Css will not say much, control the size should be able to.

Let's move on to the second correct and simple method.

Correct:

Step 1: install npm I vue-awesome-swiper-- save (according to the actual situation, install this one if the last one doesn't work)

Step 2: introduce into the main.js file

Import VueAwesomeSwiper from 'vue-awesome-swiper'Vue.use (VueAwesomeSwiper)

Introduce to the current page

Import Swiper from 'swiper';import' swiper/dist/css/swiper.min.css'

The third step

(pager)

Define a broadcast graph in data

SwiperOption: {pagination: '.swiper-pagination', paginationClickable: true, autoplay: 2500, autoplayDisableOnInteraction: false, loop: false, coverflow: {(rotation chart switching mode) rotate: 30, stretch: 10, depth: 60, modifier: 2, slideShadows: true}}

This is the end of the sharing of swiper in vue. Please give me a compliment with your help. After all, you have written so much, hehe. The common pitfalls commonly used by swiper are here, and will be updated continuously in the future.

Add: the usage of swiper in vue

First download the plug-in in vue through npm I vue-awesome-swiper-- save

And then introduce it into main.js

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

Then insert code into the structure of the component that needs to be used

Then define the broadcast graph in data

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

At this time, the coverflow is the way to switch the carousel graph to change the attribute to switch the carousel mode.

Thank you for reading! This is the end of the article on "what problems swiper will encounter in vue". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report