国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Swiper在Vue2中的使用

這篇具有很好參考價值的文章主要介紹了Swiper在Vue2中的使用。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

以swiper3為例

一、全局引入

1. 下載swiper3

cnpm install swiper@3 vue-awesome-swiper@3 --save-dev

?2.?在main.js中引入Vue-Awesome-Swiper

import VueAwesomeSwiper from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'
// 全局掛載
Vue.use(VueAwesomeSwiper)

?3.? 在swiper.vue中?

<template>
	<div>
		<swiper :options="swiperOption" ref="mySwiper">
			<swiper-slide>I'm Slide 1</swiper-slide>
			<swiper-slide>I'm Slide 2</swiper-slide>
			<swiper-slide>I'm Slide 3</swiper-slide>
			<div class="swiper-pagination" slot="pagination"></div>
		</swiper>
	</div>
</template>

<script>
export default {
	name: 'HomeSwiper',
	data () {
		return {
			swiperOption: {
				loop: true,
				autoplay: {
					delay: 3000,
					stopOnLastSlide: false,
          			disableOnInteraction: false
				},
				pagination: {
					el: '.swiper-pagination',
                    type: 'fraction',
					clickable: true
				},
			}
		}
	}
}
</script>

<style lang="scss" scoped></style>

注意分頁器的寫法

2.6.7版本

swiperOption: {
    loop: true,//可選選項,開啟循環(huán)
    autoplay: 5000,//可選選項,自動滑動
	pagination: '.swiper-pagination',
	paginationType: 'fraction',
	paginationClickable: true
}

3.1.3版本

swiperOption: {
    loop: true,
	autoplay: {
		delay: 3000,
		stopOnLastSlide: true, //當切換到最后一個slide時停止自動切換
        disableOnInteraction: true //用戶操作swiper之后,是否禁止autoplay
	},
	pagination: {
		el: '.swiper-pagination',
		type: 'fraction',
        clickable: true
	}
}

二、按需引入

1. 下載swiper3

cnpm install swiper@3 vue-awesome-swiper@3 --save-dev

?2.? 在swiper.vue中?引入樣式和組件

<template>
	<div>
		<swiper :options="swiperOption" ref="mySwiper">
			<swiper-slide>I'm Slide 1</swiper-slide>
			<swiper-slide>I'm Slide 2</swiper-slide>
			<swiper-slide>I'm Slide 3</swiper-slide>
			<div class="swiper-pagination" slot="pagination"></div>
		</swiper>
	</div>
</template>

<script>
import { swiper, swiperSlide } from "vue-awesome-swiper";
import "swiper/dist/css/swiper.css";
export default {
	name: 'HomeSwiper',
	components: {
		swiper,
		swiperSlide
	},
	data () {
		return {
			swiperOption: {
				loop: true,
				autoplay: {
					delay: 3000,
					stopOnLastSlide: false,
          			disableOnInteraction: false
				},
				pagination: {
					el: '.swiper-pagination',
					clickable: true
				}
			}
		}
	}
}
</script>

<style lang="scss" scoped></style>

loop: true失效問題

數(shù)據(jù)是寫死的時候,能夠loop:true是有效的;

數(shù)據(jù)是動態(tài)獲取的loop:true就會失效。

解決辦法:

加上v-if="list.length"有效解決文章來源地址http://www.zghlxwxcb.cn/news/detail-674667.html

computed: {
	isShowSwiper () {
		return this.list.length
	}
}

到了這里,關于Swiper在Vue2中的使用的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權(quán),不承擔相關法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • 【vue2中的pdf預覽】iframe/pdf.js/vue-pdf

    vue2中預覽pdf的方法有pdf.js和vue-pdf等。下面進行簡單對比使用方法的介紹。 使用iframe預覽pdf 如果后端返回的不是url,那么需要使用 responseType = \\\'blob\\\' 來讀取后端傳來的內(nèi)容。 擴展: 同樣是使用iframe進行預覽,如果有 其他格式 如word/xls/ppt/txt的文件需要預覽,可以使用微軟解

    2024年02月09日
    瀏覽(75)
  • vue中swiper使用

    說明:導入相應js引css import \\\"Swiper\\\" from \\\"swiper\\\" import \\\"swiper/css/swiper.css\\\"; import \\\"swiper/js/swiper\\\"; 說明:必要的結(jié)構(gòu)使用;直接封裝成一個組件? 說明:(頁面當中務必要有結(jié)構(gòu));注釋已經(jīng)寫入代碼。 第一:可以解決獲取數(shù)據(jù)在Swiper實例之前;第二:可以解決v-for遍歷完后在Swiper之

    2024年02月14日
    瀏覽(20)
  • 【vue3中使用swiper組件】

    【vue3中使用swiper組件】

    效果展示 簡介版本 安裝Swiper 項目終端中 npm i swiper 即可 這里我個人用的是 npm i swiper -S 用法 swiper/vue導出 2 個組件: Swiper 和 SwiperSlide import {Swiper, SwiperSlide} from \\\'swiper/vue\\\'; //swiper所需組件 點擊可以參考swiper中使用vue官方文檔 完整代碼展示 html靜態(tài)展示 注 :slidesPerView 為顯示

    2024年02月13日
    瀏覽(17)
  • vue中swiper輪播圖的使用

    說明:導入相應js引css import \\\"Swiper\\\" from \\\"swiper\\\" import \\\"swiper/css/swiper.css\\\"; import \\\"swiper/js/swiper\\\"; 說明:必要的結(jié)構(gòu)使用;直接封裝成一個組件? 說明:(頁面當中務必要有結(jié)構(gòu));注釋已經(jīng)寫入代碼。 第一:可以解決獲取數(shù)據(jù)在Swiper實例之前;第二:可以解決v-for遍歷完后在Swiper之

    2024年02月14日
    瀏覽(26)
  • vue使用swiper三行輪播問題

    vue使用swiper三行輪播問題

    1、輪播圖設置屬性slidesPerColumn:3實現(xiàn)不了,解決方案如下: this.scheduleData是后臺請求的數(shù)據(jù),通過3個一組分組轉(zhuǎn)換為this.scheduleListThreede 的數(shù)據(jù)! 2、邏輯處理如下: computed: { ? ? ? scheduleListThree: function () { ? ? ? ? ? let index = 0; ? ? ? ? ? let count = 3; ? ? ? ? ? let arrThree

    2024年02月09日
    瀏覽(20)
  • vue3中使用swiper(9)完整版

    vue3中使用swiper(9)完整版

    1)安裝 swiper 插件; 方法一:npm install swiper 方法二:yarn add swiper 注意:如果npm 無法安裝swiper時,使用yarn安裝; 2)參數(shù)介紹 modules: loop: 是否循環(huán)播放 slides-per-view:控制一次顯示幾張輪播圖 space-between: 每張輪播圖之間的距離,該屬性不可以和margin 屬性同時使用; aut

    2024年02月09日
    瀏覽(20)
  • 【vue+Swiper】vue中使用swiper縮略圖,展示一張大圖及n張小圖,點擊小圖切換不同的大圖展示,完整代碼

    【vue+Swiper】vue中使用swiper縮略圖,展示一張大圖及n張小圖,點擊小圖切換不同的大圖展示,完整代碼

    效果: 這是在swiper官網(wǎng)上找的示例,swiper太強大了,有非常多不同的示例,有api,有教程,還可以下載示例代碼。 但是第一次使用,研究這個縮略圖的實現(xiàn)還是花了幾個小時,好在實現(xiàn)了。 swiper官網(wǎng)請戳這里 安裝 將swiper封裝成組件可以復用,在components公共組件文件夾中新增

    2024年02月05日
    瀏覽(20)
  • vue2.x項目沒有vue.config.js時,web worker使用

    vue:2.7.14,webpack 3.6.0構(gòu)建項目 在vue中使用new Worker(‘./worker.js’)原生方法,引入woker.js子線程時,無法正常讀取引入。于是乎就百度了一下,網(wǎng)上vue使用web worker的步驟。 1.安裝使用 worker-loader // 安裝依賴包 npm install worker-loader -D 2.vue.config.js 完整配置 module.exports = { chainWebpac

    2024年02月06日
    瀏覽(27)
  • 什么是 Jest ? Vue2 如何使用 Jest 進行單元測試?Vue2 使用 Jest 開發(fā)單元測試實例

    什么是 Jest ? Vue2 如何使用 Jest 進行單元測試?Vue2 使用 Jest 開發(fā)單元測試實例

    Jest 是一個流行的 JavaScript 測試框架,由 Facebook 開發(fā)并維護,專注于簡單性和速度。它通常用于編寫 JavaScript 和 TypeScript 應用程序的單元測試、集成測試和端到端測試。 特點: 簡單易用: Jest 提供簡潔的 API 和易于理解的語法,使得編寫測試用例變得簡單快捷。 零配置:

    2024年01月25日
    瀏覽(27)
  • 以vue2為例,用npm開發(fā)環(huán)境在后端部署vue2項目(更推薦使用nginx部署)

    因為之前一致出現(xiàn)的跨域問題,從而想到了這個辦法,屬于偏方。推薦使用nginx部署,再去解決跨域問題。 接下來聊一聊本文所使用的方法。 首先將你的前端vue項目拷貝一份到服務器,準備一個dockerfile文件,用這個進行部署首先你得前提是配置好了vue.config.js的跨域配置了,

    2024年02月14日
    瀏覽(22)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包