HJ29 / vue3-qr-reader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

demo test

swana1337 opened this issue · comments

hello, i was just trying to code along the demo.
image

in the shim-vue.d.ts file i got an error: Parsing error: Imports within a declare module body must always be import type or import typeof

Can you think of why this is happening? Thanks

commented

this file isnt necessary to use this package, just revert this file back what it is before, if u dont hv this file originally, remove this file.

if i remove it i got an error in main.ts
image

if i got the other file it works

commented

i initialize a vue project with vue cli
shims-vue.d.ts orginally has these code.
Try copy these to shims-vue.d.ts?

/* eslint-disable */
declare module '*.vue' {
  import type { DefineComponent } from 'vue'
  const component: DefineComponent<{}, {}, any>
  export default component
}

now it compiles at least, but it still doesn't work to run. Nevertheless, thank you for the help :)

commented

I don't know why it doesn't work in your project.
I just create a new vue project and try to install this package
What i did,

  1. vue create testproject, cd ./testproject
  2. yarn add vue3-qr-reader
  3. modify App.vue
<template>
  <qr-stream></qr-stream>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import { QrStream } from 'vue3-qr-reader';

export default defineComponent({
  name: 'App',
  components: {
    QrStream
  }
});
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
  1. modify shims-vue.d.ts file
/* eslint-disable */
declare module '*.vue' {
  import type { DefineComponent } from 'vue'
  const component: DefineComponent<{}, {}, any>
  export default component
}

declare module 'vue3-qr-reader' {
  export {
    QrStream
  }
}
  1. yarn serve, and it works

Looks like you gave up using this package, I will close this issue.
Open issue again if you have other question, thanks.