Solve the problem of using swiper plug-in in vue

Solve the problem of using swiper plug-in in vue

Since I used this plugin when writing a demo and encountered some problems, I simply checked the usage of the plugin and some common errors.

1. Get .../maps/swiper.min.js.map 500 (Internal Server Error) appears

Source Map files missing when using min version

1. Disable Source Map prompt and delete the last line of swiper.min.js file //# sourceMappingURL=swiper.min.js.map

2. If you need to use Source Map, the complete package contains the file swiper.min.js.map, please put it in the corresponding location. About Source Map

2. The video cannot be rotated automatically and the page breaks are not displayed.

Solution:

install plus the version number.

Due to the version problem of the vue-awesome-swiper plugin package, the left and right arrow clicks may fail.

The solution is as follows:

npm uninstallvue-awesome-swiper --save

npm [email protected] --save

After installing version 3.1.3, restart and check to solve the problem

3. Error in render: "TypeError: Cannot set property 'params' of undefined" appears --- It is related to the version number. The first letter of version 4.0 is capitalized, and the first letter of version 3.0 is lowercase.

Answer link: https://github.com/surmon-china/vue-awesome-swiper/issues/499

如果使用的是3.x版本[email protected] , the import code is as follows:

import { swiper, swiperSlide } from 'vue-awesome-swiper

如果使用的是4.x版本[email protected] , the import code is as follows:

import { Swiper, SwiperSlide } from 'vue-awesome-swiper

4. Uncaught ReferenceError: Swiper is not defined at...

Maybe the JS file is not loaded or the location is wrong.

The solution is as follows:

Download the file package and load Swiper's JS and CSS files on the page, or use Swiper's CDN service to load the files, and then initialize Swiper after loading.

Vue中使用Swiper的用法如下:

The first one: global import

In main.js

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

The second method: local introduction

In the js file of the used module

import { swiper, swiperSlide } from "vue-awesome-swiper";
import "swiper/dist/css/swiper.css";
 
export default {
    
    components:
        swiper,
        swiperSlide
    }
}

In the .vue file, the left and right arrows are placed outside the carousel. The code is as follows:

<swiper class="swiper" :options="swiperOption" >
      <swiper-slide class="swiper-slide" v-for="item in 4" :key="item">
          <div class="swiper-content">{{item}}</div>
      </swiper-slide>
      <div class="swiper-pagination" slot="pagination"></div>
</swiper>
 
 <div class="swiper-button-prev" slot="button-prev"></div>
 <div class="swiper-button-next" slot="button-next"></div>

In the .vue file, the left and right arrows are placed inside the carousel. The code is as follows:

<swiper class="swiper" :options="swiperOption" >
      <swiper-slide class="swiper-slide" v-for="item in 4" :key="item">
          <div class="swiper-content">{{item}}</div>
      </swiper-slide>
      <div class="swiper-pagination" slot="pagination"></div>
      <div class="swiper-button-prev" slot="button-prev"></div>
      <div class="swiper-button-next" slot="button-next"></div>
</swiper>

The configuration information of swiperOption above is as follows. For details, please refer to the official website: https://www.swiper.com.cn/api/index.html

This is the end of this article about the error problem of using the swiper plug-in in vue. For more relevant content about using the swiper plug-in in vue, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Example of using swiper plugin to implement carousel in Vue
  • Solve the problem of using swiper plug-in in vue and the usage of swiper in vue
  • How to use the react-native package plug-in swiper
  • Solve the problem that the Swiper plug-in cannot slide in Angular.js
  • Detailed explanation of how to use the vue-awesome-swiper slider plugin
  • Example of using swiper plugin introduced in vue
  • Let's learn about the use and introduction of the Swiper plug-in

<<:  Detailed steps for installing MySQL using cluster rpm

>>:  Nginx load balancing configuration, automatic switching mode when downtime occurs

Recommend

HTML background color gradient achieved through CSS

Effect screenshots: Implementation code: Copy code...

CSS to achieve Tik Tok subscription button animation effect

I was watching Tik Tok some time ago and thought ...

What is a MySQL tablespace?

The topic I want to share with you today is: &quo...

js implementation of verification code case

This article example shares the specific code of ...

win10 docker-toolsbox tutorial on building a php development environment

Download image docker pull mysql:5.7 docker pull ...

PyTorch development environment installation tutorial under Windows

Anaconda Installation Anaconda is a software pack...

Using Docker+jenkins+python3 environment to build a super detailed tutorial

Preface: After the automation is written, it need...

IIS 7.5 uses URL Rewrite module to achieve web page redirection

We all know that Apache can easily set rewrites f...

A brief understanding of MySQL SELECT execution order

The complete syntax of the SELECT statement is: (...

MySQL decimal unsigned update negative numbers converted to 0

Today, when verifying the concurrency problem of ...

Basic usage of wget command under Linux

Table of contents Preface 1. Download a single fi...

The first step in getting started with MySQL database is to create a table

Create a database Right click - Create a new data...

Detailed tutorial on installing harbor private warehouse using docker compose

Overview What is harbor? The English word means: ...

Detailed steps for porting busybox to build a minimal root file system

Busybox: A Swiss Army knife filled with small com...