• vue-awesome-swiper轮播的使用


    一、安装vue-awesome-swiper

    npm install vue-awesome-swiper --save

    二、引入插件

    main.js里面分别引入(记得有些电脑要引入样式)
    import vueAwesomeSwiper from 'vue-awesome-swiper'
    import 'swiper/dist/css/swiper.css'
    Vue.use(vueAwesomeSwiper)

    三、使用

    <template>
        <div class="content mt40">
            <div class="banner">
                <swiper :options="swiperOption"  ref="mySwiper">  
                <!-- 这部分放你要渲染的那些内容 -->  
                <swiper-slide>
                    <img src="../../assets/images/img_1.jpg" alt=""/>
                    <div class="text-box">
                      <h2>还可以降低首付款健身房11111</h2>
                      <p>刘德华11 / 文</p>
                  </div>
                </swiper-slide>
                    <swiper-slide>
                        <img src="../../assets/images/img_2.jpg" alt=""/>
                    <div class="text-box">
                      <h2>还可以降低首付款健身房2222</h2>
                      <p>刘德华22 / 文</p>
                  </div>
                    </swiper-slide>
                <!-- 这是轮播的小圆点 -->  
                <div class="swiper-pagination banner-pagination" slot="pagination"></div>  
            </swiper>
            </div>
        </div>
    </template>
    <script>
    import { swiper, swiperSlide } from 'vue-awesome-swiper'
    export default{
        components: {  
          swiper,  
          swiperSlide  
      },  
        data(){
            return{
                swiperOption:{
                    //是一个组件自有属性,如果notNextTick设置为true,组件则不会通过NextTick来实例化swiper,
              也就意味着你可以在第一时间获取到swiper对象,假如你需要刚加载遍使用获取swiper对象来做什么事,
              那么这个属性一定要是true
    //notNextTick: true, autoplay: { delay: 3000, disableOnInteraction: false }, speed:400, autoHeight: true, loop : true, pagination: { el: '.banner-pagination', clickable: true } } } }, computed: { }, mounted(){ }, methods:{ } } </script> <style> body{ background:#f2f4f5; } .mt40{ margin-top:0.6rem; } .banner{6.4rem;position: relative;overflow: hidden; z-index: 1} .swiper-container,.swiper-wrapper{ 100%; height: 100%; } .banner .swiper-slide{100%; height:100%;} .banner .swiper-slide img{max-100%;100%; display:block;} .banner .swiper-slide .text-box{6.4rem; padding:0 0.3rem;height:1.24rem; position:absolute; left:0;
    bottom:0; color:#fff; background:rgba(0,0,0,0.5);} .text-box h2{ font-size:0.3rem; font-weight:normal; margin-top:0.22rem; line-height:100%; margin-bottom:0.22rem;
    overflow:hidden;white-space:nowrap;text-overflow:ellipsis;} .text-box p{ line-height:100%;} .banner-pagination{position:absolute; right:0.2rem;bottom:0.2rem;text-align: right;padding-right:0.3rem;} .banner-pagination .swiper-pagination-bullet{0.2rem;height:0.2rem; background:#ffffff; } .banner-pagination .swiper-pagination-bullet-active{ 0.2rem;height:0.2rem;background:#5477b2;} </style>

    就是这么简单

    日常所遇,随手而记。
  • 相关阅读:
    HBase 异步查询导致的死锁和zookeeper通信中断问题追踪与总结[非技术]
    [读书笔记]代码整洁之道读书笔记
    HBase行锁与MVCC分析
    进程、线程、轻量级进程、协程和go中的Goroutine 那些事儿
    上周回顾 - 2012年11.26-12.4
    2012年一个屌丝程序员的学习总结:读书、户外、泡妞、习惯、母猪产后护理
    C#_WinForm接收命令行参数
    SQL常识
    集成.Net / Flex3 & FluorineFX — Part II: The Client
    DB2基本概念
  • 原文地址:https://www.cnblogs.com/zhihou/p/8176113.html
Copyright © 2020-2023  润新知