# 關于swiper升級6.0后 vue接入swiper的坑
##### 最近項目重構新建了個項目,發現swiper出了點問題,在某度上搜索出來的帖子基本沒啥用,還是自己折騰
## 首先說下使用軟件版本
~~~bash
"vue": "^2.6.11",
"swiper": "^5.4.5",
"vue-awesome-swiper": "^4.1.1",
~~~
#### 坑1
以前只需要安裝vue-awesome-swiper就夠了
現在需要weiper一起安裝才行
#### 坑2
按官網教程操作后vue會報錯 找不到swiper.css
因為版本不同 項目目錄變了 點開node安裝文件夾里也只能看到'swiper/swiper-bundle.css'
如果用swiper-bundle.css會有很多問題,比如我遇到的就是分頁器不生效
這里就需要降低swiper版本了 我這里使用的是5.4.5
## 下面代碼請放心食用
~~~jsx
cnpm install vue-awesome-swiper swiper@5.4.5 --save
// 頁面代碼
<template>
<div class="recommendPage">
<swiper class="swiper" :options="swiperOption">
<swiper-slide>Slide 1</swiper-slide>
<swiper-slide>Slide 2</swiper-slide>
<swiper-slide>Slide 3</swiper-slide>
<swiper-slide>Slide 4</swiper-slide>
<swiper-slide>Slide 5</swiper-slide>
<swiper-slide>Slide 6</swiper-slide>
<swiper-slide>Slide 7</swiper-slide>
<swiper-slide>Slide 8</swiper-slide>
<swiper-slide>Slide 9</swiper-slide>
<swiper-slide>Slide 10</swiper-slide>
<div class="swiper-pagination" slot="pagination"></div>
</swiper>
</div>
</template>
<script>
import { Swiper, SwiperSlide } from 'vue-awesome-swiper'
import 'swiper/css/swiper.css'
export default {
name: 'swiper-example-pagination-dynamic',
title: 'Pagination / Dynamic bullets',
components: {
Swiper,
SwiperSlide
},
data() {
return {
swiperOption: {
autoplay: {
disableOnInteraction: false,
},
pagination: {
el: '.swiper-pagination',
dynamicBullets: true
}
}
}
}
}
</script>
<style scoped >
.recommendPage .swiper-container{
position: relative;
width: 100%;
height: 200px;
background: pink;
}
.recommendPage .swiper-container .swiper-slide{
width: 100%;
line-height: 200px;
background: yellowgreen;
color: #000;
font-size: 16px;
text-align: center;
}
</style>
~~~
### 最后說下swiper在移動端有時滑動右邊會閃爍
~~~cpp
//給外部元素的父標css套一個:
transform:translate3d(0,0,0);
overflow:hidden;
//閃動元素/子元素:
transform:translate3d(0,0,0)
~~~
作者:諍眼閉眼
鏈接:https://www.jianshu.com/p/0150d2ee109f
來源:簡書
著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請注明出處。
- 關于我們
- ApiCloud
- 支付模塊
- 微信支付--wxPay(客戶端)
- 微信支付--wxPay(服務端)
- 支付寶支付--aliPay(客戶端配置)
- 支付寶支付--aliPay(服務端配置)
- DoT模板
- 緩存模塊
- 監聽模塊
- 百度定位模塊
- 設置狀態欄字體顏色
- 選擇城市插件
- 跨頁面執行方法
- 安卓-點擊返回事件
- 上傳圖片模塊
- 點擊彈出放大圖片層
- 魅族手機apiready問題
- 分享
- 跨win或frm執行腳本
- 關于ios數字自動識別成手機號
- 百度地圖bMap
- 語音識別模塊
- tabBarMenu底部導航
- 第三方登錄
- QQ網站和appQQ賬號的統一問題解決
- 微信登錄
- QQ登錄
- 微博登錄
- 上拉加載、下拉刷新模塊
- 圖片緩存
- 文件和圖片緩存機制分享
- PHP
- 支付寶及時到賬
- no input file specified報錯解決
- thinkphp 整合kindeditor
- 整合tpshop微信模塊到thinkcmf中
- thinkphp3.1.3整合支付寶
- 網站接入QQ OAuth2.0登錄教程
- ThinkPHP整合百度編輯器Ueditor
- PHP加快執行效率的寫法規范
- ThinkPHP操作大全
- PHP操作大全
- Thinkphp中SQL操作返回值
- php5.3 foreach 使用&(與運算符)引用賦值要注意的問題
- mysql給字段追加值
- 阿里大魚短信平臺接入
- Navicat 導出 Mysql 數據字典
- php 面向對象全面教程
- PHP5下調用SOAP
- PHP處理時間格式添加空格
- 偽裝URL請求(.htaccess)
- url請求參數加解密
- JS插件
- artDialog彈窗-頁面傳值
- jQuery點擊遮罩彈出層固定居中
- jeBox原生彈窗
- bxslider輪播
- js生成指定位數隨機數
- 發送短信倒計時
- js調試
- jQuery.validator 表單驗證規則
- Swiper 輪播
- 獲得焦點時-圖片抖動
- uploadify無刷新上傳圖片
- 導航下拉隱藏上拉顯示
- 獲得焦點時-加黑色蒙版
- jquery.qrcode.js生成二維條形碼(支持中文)
- jquery.qrcode.js生成二維條形碼(官方不支持中文)
- nth-child 選擇器
- 無刷新點擊實現加載更多數據
- 刷新頁面方法
- 判斷滾動條向上向下
- 跨瀏覽器復制jQuery-zclip
- js校驗表單后提交表單的三種方法
- 用JS判斷下拉框是否選中
- div中滾動
- 提交時彈出模態框
- 當圖片不顯示時替換方法
- 前端
- CSS3
- HTML5
- css技巧
- 移動端rem
- Flex布局
- 電商詳情滾動條監聽
- VueCircleMenu圓環按鈕
- iframe自適應頁面高度
- 百度Echart
- input:radio改變選中顏色
- Jquery
- 響應式布局基本實現Media Query
- 循環輸出只輸出新內容
- 小程序
- wx.request坑
- 概要
- git操作
- 本地記住密碼
- 操作
- 生成ssh公鑰 記住密碼
- git避坑
- ES6學習手札
- 調試小插件
- 谷歌插件Postman
- PHP調試助手
- WordPress
- 緩存服務器Redis
- 在線代碼運行 Docker
- 在ubuntu下怎樣安裝https
- BrowserSync 瀏覽器同步測試工具
- getmarkman高效的設計稿標注、測量工具
- PHPstrom軟件
- 服務器
- linux 安裝搭建服務器配置及nginx配置
- tpshop的nginx 服務器配置方法
- (服務器訪問文件404解決辦法)IIS 之 添加MIME擴展類型及常用的MIME類型列表
- mysql部分
- mysql緩存
- MySql監控工具--mytop
- MySql主從搭建
- mysql優化
- Mysql 復制 (主從復制)
- iOS開發筆記 - 上線流程
- VUE避坑指南
- 從零開始學Vue
- Vue-cli
- Webpack
- VUE小記
- npm打包空白
- 打包背景圖片/項目圖片不顯示
- VUE避坑指南/elementUI upload 自定義http-request上傳
- 關于watch監聽路由重復加載方法
- 解決加載內容的時候閃動問題
- vuecli沒有network訪問地址
- python學習
- python初始
- pytho內置函數大全
- win10 播放器播放TS文件問題
- 設計網站
- VUE避坑指南/VUE-CLI部署空白
- swiper使用問題
- uni-app學習手冊
- 目錄結構
- layUI
- nodesass版本sassloader版本問題