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

vue實(shí)現(xiàn)移動(dòng)端input上傳視頻、音頻

 更新時(shí)間:2020年08月18日 11:19:02   作者:wild_guiqulaixi  
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)移動(dòng)端input上傳視頻、音頻,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

vue移動(dòng)端input上傳視頻、音頻,供大家參考,具體內(nèi)容如下

html部分

<div class="title">現(xiàn)場(chǎng)視頻</div>
 <div class="upLoad">
  <label for="pop_video" id="labelr">
  <video id="videoId" controls width="100%"></video>
  <input style="display:none;" id="pop_video" type="file" accept="video/*" capture="camcorder" v-on:change="getVideo(event, '2')" name="fileTrans" ref="file" value="">
  <div class="inputVideo">上傳視頻</div>
  </label>
 </div>
 <div class="title">現(xiàn)場(chǎng)音頻頻</div>
 <div class="upLoad">
  <label for="pop_audio" id="labelr">
  <audio id="audioId" controls width="100%"></audio>
  <input style="display:none;" id="pop_audio" type="file" accept="audio/*" capture="camcorder" v-on:change="getAudio(event, '2')" name="fileTrans" ref="file" value="">
  <div class="inputAudio">上傳音頻</div>
  </label>
</div>

js部分

getVideo (ev, typer) {
  let taht = this
  //獲取上傳文件標(biāo)簽
  let filesId = document.getElementById('pop_video');
  //獲取音頻標(biāo)簽
  let videoId = document.getElementById('videoId')
  //把當(dāng)前files[0]傳給getFileURL方法, getFileURL方法對(duì)其做一處理
  let url = this.getFileURL(filesId.files[0])
  if (url) {
  //給video標(biāo)簽設(shè)置src
  videoId.src = url
  }
  let formData = new FormData();
  formData.append("file", filesId.files[0]);
  upload(this.token, formData).then(res => {
  console.log(res)
  if (res.data.code === 0) {
   this.videoURL = res.data.data.url
  }
  })
  console.log(url)
 },
 getAudio (ev, typer) {
  let taht = this
  //獲取上傳文件標(biāo)簽
  let filesId = document.getElementById('pop_audio');
  //獲取音頻標(biāo)簽
  let audioId = document.getElementById('audioId')
  //把當(dāng)前files[0]傳給getFileURL方法, getFileURL方法對(duì)其做一處理
  let url = this.getFileURL(filesId.files[0])
  if (url) {
  //給video標(biāo)簽設(shè)置src
  audioId.src = url
  }
  let formData = new FormData();
  formData.append("file", filesId.files[0]);
  upload(this.token, formData).then(res => {
  console.log(res)
  if (res.data.code === 0) {
   this.audioURL = res.data.data.url
  }
  })
  console.log(url)
 },
 getFileURL (file) {
  let getUrl = null
  if (window.createObjectURL != undefined) {
  //basic
  getUrl = window.createObjectURL(file)
  } else if (window.URL != undefined) {//window.URL 標(biāo)準(zhǔn)定義
  //mozilla(firefox)
  //獲取一個(gè)http格式的url路徑,這個(gè)時(shí)候就可以設(shè)置<img>中的顯示
  getUrl = window.URL.createObjectURL(file)
  } else if (window.webkitURL != undefined) {//window.webkitURL是webkit的內(nèi)核
  //webkit or chrome
  getUrl = window.webkitURL.createObjectURL(file)
  }
  return getUrl 

  //video 標(biāo)簽的 duration屬性,獲取當(dāng)前視頻的長(zhǎng)度
  // let duration = videoId.duration
  // if (Math.floor(duration) > 60) {
  // that.layer.msg('視頻不能大于60秒')
  // } 
 },

css部分

#inspect .upLoad {
 background-color:#fff;
 /* height: 1.5rem; */
 text-align: left;
 padding: 0.3rem;
}

#inspect .inputVideo {
 background-color: #00cc66;
 color: #fff;
 font-size: 0.32rem;
 width: 30%;
 height: 0.8rem;
 line-height: 0.8rem;
 border-radius: 0.4rem;
 text-align: center;
 margin: 0 auto; 
}

#inspect .inputAudio {
 background-color: #5cadff;
 color: #fff;
 font-size: 0.32rem;
 width: 30%;
 height: 0.8rem;
 line-height: 0.8rem;
 border-radius: 0.4rem;
 text-align: center;
 margin: 0 auto; 
}

效果圖

關(guān)于vue.js組件的教程,請(qǐng)大家點(diǎn)擊專題vue.js組件學(xué)習(xí)教程進(jìn)行學(xué)習(xí)。

更多vue學(xué)習(xí)教程請(qǐng)閱讀專題《vue實(shí)戰(zhàn)教程》

更多精彩內(nèi)容請(qǐng)參考專題《ajax上傳技術(shù)匯總》,《javascript文件上傳操作匯總》《jQuery上傳操作匯總》進(jìn)行學(xué)習(xí)。

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

相關(guān)文章

最新評(píng)論

龙陵县| 延边| 雷州市| 天镇县| 沐川县| 灵武市| 武陟县| 峨山| 南靖县| 伊春市| 道孚县| 上虞市| 定陶县| 东光县| 墨竹工卡县| 陇川县| 清新县| 太谷县| 全州县| 山阳县| 宜春市| 仪征市| 皋兰县| 湖北省| 阿荣旗| 霍山县| 肇庆市| 巴南区| 永川市| 华亭县| 延川县| 山西省| 怀宁县| 宁城县| 博客| 共和县| 通榆县| 景德镇市| 阳新县| 汝南县| 张北县|