欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Vue登錄主頁動態(tài)背景短視頻制作

 更新時間:2019年09月21日 08:29:09   作者:`花花`  
這篇文章主要為大家詳細(xì)介紹了Vue登錄主頁動態(tài)背景短視頻的制作方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Vue制作登錄主頁動態(tài)背景短視頻的具體代碼,供大家參考,具體內(nèi)容如下

一、HTML代碼

<source src="../assets/video/G1s.mp4" type="video/mp4"/>

注:src的路徑根據(jù)自己的需要改變;

video標(biāo)簽無法自動播放 刷新后無法自動播放;

解決方法:給video標(biāo)簽添加muted屬性,可寫為muted或完整寫法:muted=“muted”

<template>
 <div class="homepage-hero-module">
  <div class="video-container">
  <div :style="fixStyle" class="filter">
   <!--內(nèi)容-->
  </div>
  <video :style="fixStyle" autoplay loop muted class="fillWidth" v-on:canplay="canplay">
   <source src="../assets/video/G1s.mp4" type="video/mp4"/>
   瀏覽器不支持 video 標(biāo)簽,建議升級瀏覽器。
   <source src="../assets/video/G1w.webm" type="video/webm"/>
   瀏覽器不支持 video 標(biāo)簽,建議升級瀏覽器。
  </video>
  <div class="poster hidden" v-if="!vedioCanPlay">
   <img :style="fixStyle" src="../assets/video/G1.jpg" alt="">
  </div>
  </div>
 </div>
</template>

二、css代碼

<style scoped>
 .homepage-hero-module,
 .video-container {
 position: relative;
 height: 100vh;
 overflow: hidden;
 }
 
 .video-container .poster img{
 z-index: 0;
 position: absolute;
 }
 
 .video-container .filter {
 z-index: 1;
 position: absolute;
 background: rgba(0, 0, 0, 0.4);
 width: 100%;
 }
 
 .fillWidth {
 width: 100%;
 }
</style>

三、JavaScript----代碼

name: '  ***  '   自定義

export default {
 name: 'Video',
 data() {
  return {
  vedioCanPlay: false,
  fixStyle: ''
  }
 },
 methods: {
  canplay() {
  this.vedioCanPlay = true
  }
 },
 mounted: function() { //屏幕自適應(yīng)
  window.onresize = () => {
  const windowWidth = document.body.clientWidth
  const windowHeight = document.body.clientHeight
  const windowAspectRatio = windowHeight / windowWidth
  let videoWidth
  let videoHeight
  if (windowAspectRatio < 0.5625) {
   videoWidth = windowWidth
   videoHeight = videoWidth * 0.5625
   this.fixStyle = {
   height: windowWidth * 0.5625 + 'px',
   width: windowWidth + 'px',
   'margin-bottom': (windowHeight - videoHeight) / 2 + 'px',
   'margin-left': 'initial'
   }
  } else {
   videoHeight = windowHeight
   videoWidth = videoHeight / 0.5625
   this.fixStyle = {
   height: windowHeight + 'px',
   width: windowHeight / 0.5625 + 'px',
   'margin-left': (windowWidth - videoWidth) / 2 + 'px',
   'margin-bottom': 'initial'
   }
  }
  }
  window.onresize()
 }
 }

四、效果演示

由于上傳大小限制,只能剪短的gif動畫了。

五、HTML版

視頻呢下載和html版代碼在官網(wǎng)最下方:https://coverr.co

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Vue中使用echarts實現(xiàn)繪制人體動態(tài)圖

    Vue中使用echarts實現(xiàn)繪制人體動態(tài)圖

    這篇文章主要為大家詳細(xì)介紹了Vue中如何使用echarts實現(xiàn)繪制人體動態(tài)圖,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2024-03-03
  • Vue keep-alive實踐總結(jié)(推薦)

    Vue keep-alive實踐總結(jié)(推薦)

    本篇文章主要介紹了Vue keep-alive實踐總結(jié)(推薦),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-08-08
  • 利用vite創(chuàng)建vue3項目的全過程及一個小BUG詳解

    利用vite創(chuàng)建vue3項目的全過程及一個小BUG詳解

    Vite作為一個構(gòu)建工具,提供了一種快速的方法來構(gòu)建Vue應(yīng)用,而Vue3?則是一個前端框架,提供了強大的功能來構(gòu)建和管理前端項目,下面這篇文章主要給大家介紹了關(guān)于利用vite創(chuàng)建vue3項目的全過程及一個小BUG的相關(guān)資料,需要的朋友可以參考下
    2023-04-04
  • antd中table展開行默認(rèn)展示,且不需要前邊的加號操作

    antd中table展開行默認(rèn)展示,且不需要前邊的加號操作

    這篇文章主要介紹了antd中table展開行默認(rèn)展示,且不需要前邊的加號操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-11-11
  • vue使用axios實現(xiàn)動態(tài)追加數(shù)據(jù)

    vue使用axios實現(xiàn)動態(tài)追加數(shù)據(jù)

    在vuejs中使用axios時,有時候需要追加數(shù)據(jù),比如,移動端下拉觸底加載,分頁加載,滑動滾動條等,下面小編就來為大家介紹一下如何使用使用axios實現(xiàn)動態(tài)追加數(shù)據(jù)吧
    2023-10-10
  • Vue 2.X的狀態(tài)管理vuex記錄詳解

    Vue 2.X的狀態(tài)管理vuex記錄詳解

    這篇文章主要介紹了Vue 2.X的狀態(tài)管理vuex記錄的相關(guān)資料,文中介紹的非常詳細(xì),對大家的理解和學(xué)習(xí)具有一定的參考價值,需要的朋友們下面來一起看看吧。
    2017-03-03
  • vue使用video.js實現(xiàn)播放m3u8格式的視頻

    vue使用video.js實現(xiàn)播放m3u8格式的視頻

    這篇文章主要為大家詳細(xì)介紹了vue如何使用video.js實現(xiàn)播放m3u8格式的視頻,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2023-12-12
  • vue-calendar-component 封裝多日期選擇組件的實例代碼

    vue-calendar-component 封裝多日期選擇組件的實例代碼

    這篇文章主要介紹了vue-calendar-component 封裝多日期選擇組件,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-12-12
  • 基于vue-router的matched實現(xiàn)面包屑功能

    基于vue-router的matched實現(xiàn)面包屑功能

    本文主要介紹了基于vue-router的matched實現(xiàn)面包屑功能,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • vue中的導(dǎo)航守衛(wèi)使用及說明

    vue中的導(dǎo)航守衛(wèi)使用及說明

    這篇文章主要介紹了vue中的導(dǎo)航守衛(wèi)使用及說明,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-01-01

最新評論