最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

使用Vue實(shí)現(xiàn)瀑布流的示例代碼

 更新時(shí)間:2024年02月06日 10:59:44   作者:天使的同類  
這篇文章主要為大家詳細(xì)介紹了如何使用Vue實(shí)現(xiàn)瀑布流,文中的示例代碼講解詳細(xì),具有一定的借鑒價(jià)值,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下

1.每個(gè)色塊寬度一致,高度自適應(yīng)

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="renderer" content="webkit">
  <meta name="viewport" content="user-scalable=0">
  <title>Vertical Line</title>
  <link rel="stylesheet" href="./common/css/style.css" rel="external nofollow"  rel="external nofollow"  rel="external nofollow" >
  <style>
    .item-move {
      transition: all .5s cubic-bezier(.55, 0, .1, 1);
      -webkit-transition: all .5s cubic-bezier(.55, 0, .1, 1);
    }
  </style>
</head>

<body>
  <div id="app">
    <waterfall :align="align" :line-gap="200" :min-line-gap="100" :max-line-gap="220" :single-max-width="300"
      :watch="items" @reflowed="reflowed" ref="waterfall">
      <!-- each component is wrapped by a waterfall slot -->
      <waterfall-slot v-for="(item, index) in items" :width="item.width" :height="item.height" :order="index"
        :key="item.index" move-class="item-move">
        <div class="item" :style="item.style" :index="item.index"></div>
      </waterfall-slot>
    </waterfall>
  </div>
  <script src="https://cdn.jsdelivr.net/vue/2.2.6/vue.min.js"></script>
  <script src="http://app.moptym.com/cdn/vue-waterfall/vue-waterfall.min.js"></script>
  <script src="./common/js/item-factory.js"></script>
  <script>

    var app = new Vue({
      el: '#app',
      components: {
        'waterfall': Waterfall.waterfall,
        'waterfall-slot': Waterfall.waterfallSlot
      },
      data: {
        align: 'center',
        items: ItemFactory.get(100),
        isBusy: false
      },
      methods: {
        addItems: function () {
          if (!this.isBusy && this.items.length < 500) {
            this.isBusy = true
            this.items.push.apply(this.items, ItemFactory.get(50))
          }
        },
        shuffle: function () {
          this.items.sort(function () {
            return Math.random() - 0.5
          })
        },
        reflowed: function () {
          this.isBusy = false
        }
      }
    })

    document.body.addEventListener('click', function () {
      app.shuffle()
      // app.$refs.waterfall.$emit('reflow') // manually trigger reflow action
    }, false)

    window.addEventListener('scroll', function () {
      var scrollTop = document.documentElement.scrollTop || document.body.scrollTop
      if (scrollTop + window.innerHeight >= document.body.clientHeight) {
        app.addItems()
      }
    })

  </script>
</body>

</html>

如圖所示:

2.每個(gè)色塊高度一致,寬度自適應(yīng)

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="renderer" content="webkit">
  <meta name="viewport" content="user-scalable=0">
  <title>Horizontal Line</title>
  <link rel="stylesheet" href="./common/css/style.css" rel="external nofollow"  rel="external nofollow"  rel="external nofollow" >
  <style>
    .item-move {
      transition: all .5s cubic-bezier(.55, 0, .1, 1);
      -webkit-transition: all .5s cubic-bezier(.55, 0, .1, 1);
    }
  </style>
</head>

<body>
  <div id="app">
    <waterfall :line="line" :line-gap="200" :min-line-gap="180" :max-line-gap="220" :watch="items" @reflowed="reflowed"
      ref="waterfall">
      <!-- each component is wrapped by a waterfall slot -->
      <waterfall-slot v-for="(item, index) in items" :width="item.width" :height="item.height" :order="index"
        :key="item.index" move-class="item-move">
        <div class="item" :style="item.style" :index="item.index"></div>
      </waterfall-slot>
    </waterfall>
  </div>
  <script src="https://cdn.jsdelivr.net/vue/2.2.6/vue.min.js"></script>
  <script src="http://app.moptym.com/cdn/vue-waterfall/vue-waterfall.min.js"></script>
  <script src="./common/js/item-factory.js"></script>
  <script>

    var app = new Vue({
      el: '#app',
      components: {
        'waterfall': Waterfall.waterfall,
        'waterfall-slot': Waterfall.waterfallSlot
      },
      data: {
        line: 'h',
        items: ItemFactory.get(100),
        isBusy: false
      },
      methods: {
        addItems: function () {
          if (!this.isBusy && this.items.length < 500) {
            this.isBusy = true
            this.items.push.apply(this.items, ItemFactory.get(50))
          }
        },
        shuffle: function () {
          this.items.sort(function () {
            return Math.random() - 0.5
          })
        },
        reflowed: function () {
          this.isBusy = false
        }
      }
    })

    document.body.addEventListener('click', function () {
      app.shuffle()
      // app.$refs.waterfall.$emit('reflow') // manually trigger reflow action
    }, false)

    window.addEventListener('scroll', function () {
      var scrollTop = document.documentElement.scrollTop || document.body.scrollTop
      if (scrollTop + window.innerHeight >= document.body.clientHeight) {
        app.addItems()
      }
    })

  </script>
</body>

</html>

如圖所示:

3.寬高不限制,每個(gè)色塊順著排

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="renderer" content="webkit">
  <meta name="viewport" content="user-scalable=0">
  <title>Vertical Line With Grow</title>
  <link rel="stylesheet" href="./common/css/style.css" rel="external nofollow"  rel="external nofollow"  rel="external nofollow" >
  <style>
    .item-move {
      transition: all .5s cubic-bezier(.55, 0, .1, 1);
      -webkit-transition: all .5s cubic-bezier(.55, 0, .1, 1);
    }
  </style>
</head>

<body>
  <div id="app">
    <waterfall :grow="grow" :watch="items" @reflowed="reflowed" ref="waterfall">
      <!-- each component is wrapped by a waterfall slot -->
      <waterfall-slot v-for="(item, index) in items" :width="item.width" :height="item.height" :order="index"
        :key="item.index" move-class="item-move">
        <div class="item" :style="item.style" :index="item.index"></div>
      </waterfall-slot>
    </waterfall>
  </div>
  <script src="https://cdn.jsdelivr.net/vue/2.2.6/vue.min.js"></script>
  <script src="http://app.moptym.com/cdn/vue-waterfall/vue-waterfall.min.js"></script>
  <script src="./common/js/item-factory.js"></script>
  <script>

    var app = new Vue({
      el: '#app',
      components: {
        'waterfall': Waterfall.waterfall,
        'waterfall-slot': Waterfall.waterfallSlot
      },
      data: {
        grow: [3, 2, 1, 2],
        items: ItemFactory.get(100),
        isBusy: false
      },
      methods: {
        addItems: function () {
          if (!this.isBusy && this.items.length < 500) {
            this.isBusy = true
            this.items.push.apply(this.items, ItemFactory.get(50))
          }
        },
        shuffle: function () {
          this.items.sort(function () {
            return Math.random() - 0.5
          })
        },
        reflowed: function () {
          this.isBusy = false
        }
      }
    })

    document.body.addEventListener('click', function () {
      app.shuffle()
      // app.$refs.waterfall.$emit('reflow') // manually trigger reflow action
    }, false)

    window.addEventListener('scroll', function () {
      var scrollTop = document.documentElement.scrollTop || document.body.scrollTop
      if (scrollTop + window.innerHeight >= document.body.clientHeight) {
        app.addItems()
      }
    })

  </script>
</body>

</html>

如圖所示:

到此這篇關(guān)于使用Vue實(shí)現(xiàn)瀑布流的示例代碼的文章就介紹到這了,更多相關(guān)Vue瀑布流內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • vue+element-ui+sortable.js實(shí)現(xiàn)表格拖拽功能

    vue+element-ui+sortable.js實(shí)現(xiàn)表格拖拽功能

    這篇文章主要為大家詳細(xì)介紹了vue+element-ui+sortable.js實(shí)現(xiàn)表格拖拽功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • Vue.2.0.5實(shí)現(xiàn)Class 與 Style 綁定的實(shí)例

    Vue.2.0.5實(shí)現(xiàn)Class 與 Style 綁定的實(shí)例

    本篇文章主要介紹了Vue.2.0.5實(shí)現(xiàn)Class 與 Style 綁定的實(shí)例,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • keep-alive include和exclude無(wú)效問(wèn)題及解決

    keep-alive include和exclude無(wú)效問(wèn)題及解決

    這篇文章主要介紹了keep-alive include和exclude無(wú)效問(wèn)題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-11-11
  • vue項(xiàng)目中canvas實(shí)現(xiàn)截圖功能

    vue項(xiàng)目中canvas實(shí)現(xiàn)截圖功能

    這篇文章主要為大家詳細(xì)介紹了vue項(xiàng)目中canvas實(shí)現(xiàn)截圖功能,截取圖片的一部分,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • nginx部署訪問(wèn)vue-cli搭建的項(xiàng)目的方法

    nginx部署訪問(wèn)vue-cli搭建的項(xiàng)目的方法

    本篇文章主要介紹了nginx部署訪問(wèn)vue-cli搭建的項(xiàng)目的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-02-02
  • vue封裝公共方法的實(shí)現(xiàn)代碼

    vue封裝公共方法的實(shí)現(xiàn)代碼

    這篇文章給大家介紹了vue封裝公共方法的實(shí)現(xiàn),文章中通過(guò)代碼示例給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作有一定的幫助,需要的朋友可以參考下
    2024-01-01
  • 解決IE11 vue +webpack 項(xiàng)目中數(shù)據(jù)更新后頁(yè)面沒(méi)有刷新的問(wèn)題

    解決IE11 vue +webpack 項(xiàng)目中數(shù)據(jù)更新后頁(yè)面沒(méi)有刷新的問(wèn)題

    今天小編就為大家分享一篇解決IE11 vue +webpack 項(xiàng)目中數(shù)據(jù)更新后頁(yè)面沒(méi)有刷新的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-09-09
  • Vue中的虛擬dom分享

    Vue中的虛擬dom分享

    虛擬DOM是一種用JavaScript對(duì)象來(lái)描述真實(shí)DOM的技術(shù),通過(guò)diff算法實(shí)現(xiàn)高效的DOM更新,提高頁(yè)面性能,Vue通過(guò)render函數(shù)和VNode實(shí)現(xiàn)虛擬DOM,結(jié)合diff算法減少DOM操作,提升用戶體驗(yàn)
    2024-12-12
  • 前端vuex中dispatch的使用方法總結(jié)

    前端vuex中dispatch的使用方法總結(jié)

    這篇文章主要給大家介紹了關(guān)于前端vuex中dispatch使用方法的相關(guān)資料,vuex的dispatch方法用于觸發(fā)一個(gè)action,以便更新state,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-04-04
  • vue實(shí)現(xiàn)數(shù)字變換動(dòng)畫(huà)的示例代碼

    vue實(shí)現(xiàn)數(shù)字變換動(dòng)畫(huà)的示例代碼

    本文主要介紹了vue實(shí)現(xiàn)數(shù)字變換動(dòng)畫(huà)的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-04-04

最新評(píng)論

垦利县| 谷城县| 大关县| 新安县| 自贡市| 泌阳县| 娱乐| 永嘉县| 清水县| 汉源县| 陈巴尔虎旗| 西华县| 巴林左旗| 镇雄县| 娄烦县| 务川| 牙克石市| 武安市| 吴川市| 桑日县| 和顺县| 乐至县| 腾冲县| 红桥区| 株洲市| 北辰区| 渑池县| 南部县| 博爱县| 霞浦县| 治县。| 忻城县| 兰考县| 鹿泉市| 桐乡市| 上虞市| 汝州市| 宁夏| 收藏| 花垣县| 酒泉市|