上传图片二维码扫描qr-scanner-wechat

<script setup lang="ts">
  import { scan,ready } from "qr-scanner-wechat";
  import {ref} from "vue"
  const src = ref("")
  const imgEl = ref<HTMLImageElement>()
  imgEl.value = document.getElementById("img")
  const  getImageFromLocal = async (e: Event)=> {
  const inputEl = e.target as HTMLInputElement;
  if (!inputEl) return;
  console.log("inputEl.files", inputEl.files);
  const image = inputEl.files[0];
  console.log(imgEl.value)
  const url = URL.createObjectURL(image);
  src.value = url 
  imgEl.value.src = src
  await ready()
  const result = await scan(imgEl.value!);
  console.log(result)
}


</script>
 <div>
   <input type="file" accept="image/png" />
   <img :src="src" alt="" id="img" ref="imgEl">
</div>

你可能感兴趣的:(uniapp,微信)