# Video 摄像头

调取原生的摄像头调用开始函数和结束函数,停止后即可获取录制片段

TIP

2.1.0



    <el-button @click="startRecord" v-if="!flag" type="primary">开始录制</el-button>
    <el-button type="danger" @click="stopRecord" v-else>停止录制</el-button>
    <br /><br />
    <avue-video background="https://avuejs.com/images/face.png" @data-change="dataChange" ref="video"></avue-video>
<script>
export default {
  data(){
    return {
      flag:false
    }
  },
  methods: {
      startRecord() {
        this.flag=true;
        this.$message.success('开始录制')
        this.$refs.video.startRecord();
      },
      stopRecord() {
        this.flag=false;
        this.$message.success('请看控制台视频文件的base64')
        this.$refs.video.stopRecord();
      },
      dataChange(data) {
        console.log(data);
      }
    }
}
</script>

Expand Copy
Last Updated: 7/29/2021, 2:59:35 PM