current position:Home>Swiper, the application of swiper in Vue, and various versions of swiper are applied in Vue projects
Swiper, the application of swiper in Vue, and various versions of swiper are applied in Vue projects
2022-04-29 07:37:08【imkaifan】
background
direct npm install swiper I found it swiper8 edition According to the official website tutorial in vue2 Play without turning , So I chose to downgrade , By the way swiper Have a look , I haven't used it for a long time .
About swiper
At present swiper It's already here 8 edition .
6 Version and above , It has supported the use directly in the front-end framework .
6 The following versions , It is not supported to use directly in the front-end framework .
in other words , 6 The following versions , No, swiper-vue.js
swiper7、8 Can't be in vue2 Use in :
as a result of , stay swiper Source code , Introduced 8 individual vue Methods are vue3 The method in , stay vue2 Does not exist in the .
If in vue2 Use in swiper7、8 Will report a mistake .
stay vue3 Introduction in swiper7、8 There will be errors in the path
The official website code is as follows :( To introduce , Relevant modules will not be found )
// Import Swiper Vue.js components
import {
Swiper, SwiperSlide } from 'swiper/vue';
// Import Swiper styles
import 'swiper/css';
The right way to introduce
// Import Swiper Vue.js components
import {
Swiper, SwiperSlide } from 'swiper/vue/swiper-vue.js';
// Import Swiper styles
import 'swiper/swiper.min.css';
The project time is urgent , And it's vue2 Project , So I chose 6 Before the release , The most stable 5.4.5
Load after the page is loaded swiper
<script>
import Swiper from 'swiper'; // Notice the introduction of Swiper
import 'swiper/css/swiper.min.css' // Note the introduction here
export default {
name: 'CarouselShow',
mounted() {
new Swiper('.swiper-container', {
autoplay: true,
loop: true,
})
}
}
</script>
Use steps
1、npm install [email protected]
2、 introduce
3、swiper Of api Configuration item
<template>
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide swiper-slide1">Slide 1</div>
<div class="swiper-slide swiper-slide2">Slide 2</div>
<div class="swiper-slide swiper-slide3">Slide 3</div>
</div>
<!-- If you need a pager -->
<div class="swiper-pagination"></div>
<!-- If you need a navigation button -->
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
</template>
<script>
import Swiper from 'swiper'; // Notice the introduction of Swiper
import 'swiper/css/swiper.min.css' // Note the introduction here
export default {
name: 'HelloWorld',
data() {
return {
// swiper example There are various methods on examples
swiperInstance: null
}
}
mounted() {
var swiperInstance = new Swiper('.swiper-container', {
// config...
})
}
}
</script>
<style scoped>
</style>
copyright notice
author[imkaifan],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204290528481053.html
The sidebar is recommended
- How to realize Ethernet wireless communication between 200smartplc?
- Still working on nginx configuration? Try this visual configuration tool. It's really powerful!
- Simple sorting of JavaScript deep copy and shallow copy
- React realizes the communication of brother components by means of message subscription and publication
- React limits props
- Java lesson 30
- Java lesson 29 136 The number 1189 appears only once Maximum number of balloons
- Simple sorting of JavaScript deep copy and shallow copy
- "Geely" new SUV is equipped with frameless doors, and the interior is more beautiful than Mercedes Benz. Can 19 universal accept it?
- Configuration of using less in react project
guess what you like
Expression used in react render
React configuration agent
JQuery sends a post request (a method of connecting PHP variables to strings)
Solve the problem that Django cannot access the local server( http://127.0.0.1:8000/ )Or the problem that the command line execution (Python 3 manage.py runserver 0.0.0.0:8000) does not respond
Summary of the writing method of react router V6
Bipeng ditch, punch in and net red, open-air boundless swimming pool, Ramada hot spring, encounter the beauty of the four seasons
JavaScript gets and modifies elements. What's wrong with not extracting the classlist attribute
Mixed mixin of Vue
Vue + element implements table filtering
Vue router2. 0
Random recommended
- Which one charges less for opening a securities account and how to open the account
- Spring MVC notes 02 domain object sharing data, view, restful, httpmessageconverter, file upload and download
- Httpclient setting timeout
- Command line / Python uses pdf2htmlex to convert PDF to HTML
- [front end three swordsmen III] analysis of JavaScript scalpel Part II
- How to choose the front-end learning path
- Finite element parametric element, calculation, theoretical problems
- Handwritten CSS modules to understand its principle
- Front end browser debugging tips
- Performance problem analysis guide for enterprise JavaScript applications running in production systems
- CSS aspect-ratio All In One
- Actual combat of vue3 project --- Zhihu daily --- details page
- Actual combat of vue3 project --- Zhihu daily --- home page function
- Great Wall Motors is falling endlessly! The boss has lost 150 billion yuan in half a year, and the performance of the new energy sector has improved
- Nginx tips batch shutdown process
- Openresty introduces nginx_ upstream_ check_ Module module
- Nginx multiple servers_ How does name match
- Why does the front end still prompt cannot post, and the error reported by the back end still prompt null pointer?
- HTML Li set margin: 50%, but the width of the outermost div is the standard
- Are there any specific steps to create a prototype, such as JavaScript?
- How does HTML5 display the value obtained from the database in the specified area
- Problems related to nginx rewriting interface
- What happens when you open a CSS file in eclipse without responding
- React download local template can be downloaded locally, but the deployment online download is blank
- @Babel / traverse official example running error: typeerror: traverse is not a function
- The click event of jQuery has no effect
- How to learn from non professional background?
- Usage of API documented as @since 1.8+ less... (Ctrl+F1) Inspection info: This inspection finds all
- Configuration Vue of webpack
- Introduction to nginx (learning notes)
- Is the financial management class of qiniu school true? Can you learn how to manage money in free lessons
- How does Java randomly get elements from a list
- Use of Vue on in Vue
- Use of Vue router
- Vue basic syntax
- Use of webpack
- Vue diff algorithm
- CSS -- Text gradient from top to bottom
- Routing: Vue router
- Leetcode 658. Find K closest elements