vue-awsome-swiper稳定版本3.1.3及使用方法,API见swiper官网https://www.swiper.com.cn/api/index.html

1.npm和yarn安装/卸载执行命令

// 安装依赖
npm install
yarn install

// npm安装/移除插件命令
//页面相关引用都要清除

npm install xxx —save 
npm uninastall xxx —save

// yarn安装/移除插件命令
//页面相关引用都要清除

yarn add xxx
yarn remove xxx

2.安装方法:

npm安装

npm install vue-awesome-swiper@3.1.3 --save

 yarn安装

yarn add vue-awesome-swiper@3.1.3

 3.vue-awsome-swiper引用方式

按照组件形式局部导入:

import { swiper, swiperSlide } from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'
export default {
    name: 'Index',
    components: {
        swiper,
        swiperSlide
    },
     data(){
         return{
            }
           }
}

或者全局导入(大家不推荐,我也不推荐):

import Vue from 'vue'
import VueAwesomeSwiper from 'vue-awesome-swiper'

// require styles
import 'swiper/dist/css/swiper.css'

Vue.use(VueAwesomeSwiper, /* { default global options } */)

案列:

<template>
    <div v-loading="loading" class="table-container" element-loading-background="rgba(0, 0, 0, 0)">
        <div class="table_head">
            <ul class="table_head--list">
                <li class="smooth">xxx</li>
                <li class="smooth">xxx</li>
                <li class="smooth">xxx</li>
          
                <li class="danger">xxx</li>
                <li class="orange">xxx</li>
                <li class="warn">xxx</li>
                <li class="green">xxx</li>
            </ul>
        </div>
        <!-- 滚动-->
        <div class="seamless-warp" @mouseenter="on_top_enter" @mouseleave="on_top_leave">
            <swiper
                v-if="listData.length > 1"
                ref="mySwiper"
                class="item"
                :options="swiperOption"
            >
                <swiper-slide
                    v-for="(item,index) in listData"
                    :key="index"
                    class="swiperslide"
                >
                    <div class="listdata" @click.stop.prevent="router(item.id)">
                        <span class="title" v-text="$isEmpty(item.profile.realName)?'-':item.profile.realName" />
                        <span class="date" v-text="$isEmpty(item.profile.phone)?'-':item.profile.phone" />
                        <span class="date" v-text="$isEmpty(item.profile.idCard)?'-':item.profile.idCard" />
                        <span class="date" v-text="trainTime(item.labourTrainingPlan, '3')" />
                        <span class="date" v-text="trainTime(item.labourTrainingPlan, '1')" />
                        <span class="date" v-text="trainTime(item.labourTrainingPlan, '2')" />
                        <span class="date" v-text="trainTime(item.labourTrainingPlan, '4')" />
                    </div>
                </swiper-slide>
            </swiper>
            <div v-else class="is-swiper-none titleblue">暂无数据</div>
        </div>
    </div>

</template>

<script>
import { swiper, swiperSlide } from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'
import { listEmployee, trainCount } from '@/api/qzg'
const vm = this
export default {
    name: 'Index',
    components: {
        swiper,
        swiperSlide
    },
    data() {
        return {
            current: 1,
            timer: undefined,
            queryParams: {
                teamId: this.$store.getters.teamId,
                projectId: this.$store.getters.projectId,
                contractSectId: undefined
            },
            contractId: '',
            sysId: '',
            // swiper轮播
            swiperOption: { // swiper3
                /* autoplay: { // 自动轮播
                    delay: 3000,
                    disableOnInteraction: false
                },*/
                /* loop: true,
                observer: true, // 修改swiper自己或子元素时,自动初始化swiper
                observeParents: true, // 修改swiper的父元素时,自动初始化swiper
                autoplay: {
                    delay: 3000,
                    disableOnInteraction: false // 手动滑动后继续自动播放
                },
                direction: 'vertical',
                slidesPerView : 7,
                centeredSlides: false,
                centeredSlidesBounds: false*/
            },
            // 数据数组
            listData: [],
            loading: false
           
        }
    },
    computed: {
        mySwiper() {
            return this.$refs.mySwiper.swiper
        },
        trainTime() {
            return (value, type) => {
                const results = value.filter(item => item.trainingType === type)
                return this.$isNotEmpty(results) ? results[0].trainingTime : '-'
            }
        }
    },
    created() {
        this.loading = true
        this.$nextTick(() => {
            this.listSwiper()
        })
        this.getOptions()
        this.timer = setInterval(() => {
            this.current++
            this.getOptions()
        }, 5000)
        this.loading = true
        
    },
    methods: {
        router(id) {
            this.sysId = 'fc68a49a549df12e9a6ab6cb81065f82'
            this.$store.dispatch('setSystemId', this.sysId).then(() => {
                window.open(`${process.env.VUE_APP_ADDRESS}labour/employee/addPages?type=edit&paramId=` + id, '_blank')
            })
        },
        // 获取接口数据
        getOptions() {
            listEmployee({
                current: this.current,
                pageSize: 15,
                params: {
                    teamId: this.$store.getters.teamId,
                    projectId: this.$store.getters.projectId,
                    status: '0'
                }
            }).then(res => {
                this.loading = false
                this.listData.push(...res.rows)
                if (this.listData.length === res.total) {
                    clearInterval(this.timer)
                }
            })
        },
        // 轮播方法
        listSwiper() {
            this.swiperOption = { // 控制大于4张图片的时候自动轮播
                loop: true,
                mousewheel: true,
                observer: true, // 修改swiper自己或子元素时,自动初始化swiper
                observeParents: true, // 修改swiper的父元素时,自动初始化swiper
                autoplay: {
                    delay: 3000,
                    disableOnInteraction: false // 手动滑动后继续自动播放
                },
                speed: 1000,
                direction: 'vertical',
                slidesPerView: 5,
                slidesPerGroup: 5
            }
           /* this.listData.length >= 5 ? this.swiperOption = { // 控制大于4张图片的时候自动轮播
             loop: true,
             observer: true, // 修改swiper自己或子元素时,自动初始化swiper
             observeParents: true, // 修改swiper的父元素时,自动初始化swiper
             autoplay: {
                 delay: 5000,
                 disableOnInteraction: false // 手动滑动后继续自动播放
             },
             speed:1000,
             direction: 'vertical',
             slidesPerView : 5,  // 显示5条数据
             slidesPerGroup : 5, // 5条数据为一组
         } : this.swiperOption = {
             autoplay: false,
             slidesPerView: 5, //
             direction: 'vertical',
             loop: false, // 无限轮播
             simulateTouch: false // 禁止鼠标模拟
         }*/
           
        },
        // 鼠标进入停止自动轮播
        on_top_enter() {
            this.mySwiper.autoplay.stop()
        },
        // 鼠标移除自动轮播
        on_top_leave() {
            this.mySwiper.autoplay.start()
        }
    }
}
</script>

<style lang="scss" scoped>
    .table-container{
        width: 100%;
        height: 100%;
        overflow: hidden;
        .table_head{
            width: 100%;
            height: 20%;
            &--list{
                width: 100%;
                height: 40px;
                display: flex;
                justify-content: space-between;
                align-items: center;
                font-size: 14px;
                color: #ffffff;
                margin:0;
                background: linear-gradient(0deg, rgba(13, 95, 215, 0.1),rgba(13, 95, 215, 0.3));
                & > li{
                    width: 13%;
                    text-align: center;
                    /*flex: 1;*/
                }
                & > li:first-child,& > li:nth-child(2){
                    width: 7%;
                }
            }
        }
/*
        .swiper-slide-active{
            background: rgba(0, 26, 68, 0.7);
        }*/

        .seamless-warp {
            height: 80%;
            overflow: hidden;
            padding: 5px 0;
            display: flex;
            justify-content:center;
            align-items: center;
            .item{
                color: #fff;
                list-style: none;
                .listdata{
                    width: 100%;
                    /*height: 27px;*/
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    cursor: pointer;
                    & > span{
                        /*flex: 1;*/
                        width: 13%;
                        font-size: 12px;
                        text-align: center;
                    }
                    & > span:first-child,& > span:nth-child(2){
                        width: 7%;
                    }
                }
                /*.swiperslide:nth-child(2n){
                    background: rgba(0, 26, 68, 1);
                }*/
            }
        }
    }

</style>
<style lang="scss" scoped>
    .swiper-container{
        width: 100%;
        height: 100%;
    }
    .swiperslide{
        display: flex;
        align-items: center;
    }
    .swiperslide:nth-of-type(odd){
        background: rgba(0, 26, 68, 1);
    }
</style>

 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用:npm ERR! 404 Not Found - GET https://registry.npmmirror.com/@vue/vue-loader-v15 - [NOT_FOUND] @vue/vue-loader-v15 not found vue 安装npm i element-ui -S 等 组件 报错 npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmmirror.com/@vue/vue-loader-v15 - [NOT_FOUND] @vue/vue-loader-v15 not found npm ERR! 404 npm ERR! 404 '@vue/vue-loader-v15@15.10.0' is not in the npm registry. npm ERR! 404 You should bug the author to publish it (or use the name yourself!) npm ERR! 404 It was specified as a dependency of '@vue/cli-service' npm ERR! 404 npm ERR! 404 Note that you can also install from a npm ERR! 404 tarball, folder, http url, or git url. 根据引用的内容,这个错误是由于找不到vue-awesome-swiper的tarball数据所导致的。vue-awesome-swiper的tarball数据位于http://172.168.251.67:4873/vue-awesome-swiper/-/vue-awesome-swiper-3.1.3.tgz。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [npm install -g cnpm --registry=https://registry.npm.taobao.org报错](https://blog.csdn.net/qq_36853469/article/details/99900961)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [ist的matlab代码-gitlab-uberspace-tutorial:如何在https://uberspace.de上安装GitLab](https://download.csdn.net/download/weixin_38543120/19078868)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [ 404 Not Found - GET https://registry.npmmirror.com/@vue%2fvue-loader-v15 - [NOT_FOUND] @vue](https://blog.csdn.net/qq_51307593/article/details/127484795)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值