美文网首页
vue3+vue3-qr-reader H5调用手机摄像头扫一扫

vue3+vue3-qr-reader H5调用手机摄像头扫一扫

作者: 爱代码的派派星 | 来源:发表于2022-06-24 15:10 被阅读0次
    <template>
      <div class="main-mine">
      <div class="stream">
        <qr-stream @decode="onDecode" class="mb" >
          <div style="color: red;" class="frame"></div>
        </qr-stream>
      </div>
      <div class="result">
        Result: {{data}}
      </div>
      </div>
    </template>
    
    <script lang="ts">
    import { QrStream, QrCapture, QrDropzone } from 'vue3-qr-reader';
    import { defineComponent, ref, Ref, reactive, toRefs } from 'vue'
    export default defineComponent({
      name: 'Qrcode3',
      components: {
        QrStream,
        QrCapture,
        QrDropzone
      },
      setup() {
        const state = reactive({
          data: null
        })
        const onDecode = (data: any) => {
          state.data = data
        }
        return {
          ...toRefs(state),
          onDecode,
        }
      }
    })
    </script>
    <style lang="less" scoped>
    .main-mine {
      background: #ccc;
    }
    </style>
    

    相关文章

      网友评论

          本文标题:vue3+vue3-qr-reader H5调用手机摄像头扫一扫

          本文链接:https://www.haomeiwen.com/subject/smavvrtx.html