zoukankan      html  css  js  c++  java
  • vue.js中引入swiper.js

    1.下载swiper.js

      npm install vue-awesome-swiper --save

    2.在main.js中全局引入swiper.js

      import VueAwesomeSwiper from 'vue-awesome-swiper' 

      import 'swiper/dist/css/swiper.css'

      Vue.use(VueAwesomeSwiper)

    3.在模板中配置相关内容

    <template>

      <swiper :options="swiperOption">
        <swiper-slide v-for="item in imglist">
          <img :src="rootLink+ '/resources/img/' + item.imgPath"/>
        </swiper-slide>
        <div class="swiper-pagination" slot="pagination"></div>
      </swiper>
    </template>

    <script>
    import axios from 'axios'
    export default {
      name: 'carrousel',
      data() {
        return {
          rootLink: 'http://119.23.28.239:8080',
          imglist:[],
          swiperOption: {
            autoplay: 3000,  //l轮播间隔时间
            loop: true,  //是否自动轮播
            pagination : '.swiper-pagination', //轮播图中下标点显示
            paginationClickable :true   //轮播图中下标点显示
          }
         }
      },
      mounted() {
        var vm = this;
        axios.get(vm.rootLink + '/train/homePage/banner?type=上面')
        .then(function (data) {
          vm.imglist = data.data.data
        })
      }
    }
    </script>

  • 相关阅读:
    js基础面试篇
    vue自定义指令
    vue兄弟节点通信
    vue----打包上线引用外部cdn
    vue----mockjs
    laravel database opearate1
    laravel seeding
    backtotop组件
    配置节流函数
    failed at the chromedriver@2.33.2 install script
  • 原文地址:https://www.cnblogs.com/wangpeiyuan/p/8086535.html
Copyright © 2011-2022 走看看