jquery-backstretch具有幻灯片显示功能的背景图插件的笔记

1、安装

1-1、从GitHub下载/保存JS文件

https://github.com/jquery-backstretch/jquery-backstretch

2-1、npm安装

npm i jquery-backstretch

2、使用:

2-1、Backstretch幻灯片演示与延迟加载配合使用:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="jquery.backstretch.min.js"></script>
<script>
    $.backstretch([
      "pot-holder.jpg",
      "coffee.jpg",
      "dome.jpg"
      ], {
        fade: 750,
        duration: 4000,
        preload: 1, //Use the lazy-loading functionality
        start: 2 //Optional - now starts with "dome.jpg"
    });
</script>

2 -2、Backstretch创建背景图像的幻灯片显示

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="jquery.backstretch.min.js"></script>
<script>
    $.backstretch([
      "pot-holder.jpg",
      "coffee.jpg",
      "dome.jpg"
      ], {
        fade: 750,
        duration: 4000
    });
</script>

2-3、背景图像的幻灯片随机过渡

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="jquery.backstretch.min.js"></script>
<script>
    $.backstretch([
      "pot-holder.jpg",
      "coffee.jpg",
      "dome.jpg"
      ], {
        duration: 4000,
        transition: 'push_left|push_right|cover_up|cover_down|fade',
        transitionDuration: 250
    });
</script>

4、在vue中应用

<div class="container"></div>
<script>
import '../../node_modules/jquery-backstretch/jquery.backstretch.min.js'
export default {
  name: "home",
  data() {
    return {
    }
  },
  mounted(){
    this.initSwiper()
  },
  methods:{
    initSwiper(){
      console.log($('.container').css('height'))
      $('.container').backstretch([
      "http://b.hi1e41cd/0eb30f2442a7d9337119f7dba74bd11372f001e0.jpg",
      "http://b3.jpg",
      "http://f525.jpg"
      ], {
        fade: 750,
        duration: 1000,
        preload: 1, //Use the lazy-loading functionality
        start: 2 //Optional - now starts with "dome.jpg"
    });
  }
  }
};
</script>

 

<style lang="scss">
  .container{
    width: 600px;
    height: 400px;
  }
</style>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值