How to elegantly use the swiper plugin in a Vue project

Before starting, please make sure you have a webpack template-based project (vue-cli scaffolding one-click installation~)

1. npm command to install swiper

npm install swiper --save-dev

2. Introduce swiper to components that require swiper plugins

import Swiper from "swiper"

3. Introduce the css of the swiper plugin in the component style (choose according to your own project path)


4. Initialize the swiper plugin in the methods method


5. Called in the created hook function


OK......

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325819788&siteId=291194637