vue使用QrCode识别二维码初始化报错

最近在做一个vue实现上传识别二维码的功能,上网查了很多,基本上都是在用qrcode-decoder,在初始化qrCode的时候报错Uncaught TypeError: qrcode_decoder__WEBPACK_IMPORTED_MODULE_0___default(...) is not a constructor,请教各位怎么解决?

页面代码使用el-upload获取文件

<el-upload
      class="avatar-uploader"
      action=""
      :show-file-list="false"
      :on-change = "decodeQrCode"
    >
      <img v-if="imageUrl" :src="imageUrl" class="avatar" />
      <i v-else class="el-icon-plus avatar-uploader-icon"></i>
    </el-upload>
getObjectURL(file){
      var url = null;
      if (window.createObjectURL != undefined) { // basic
          url = window.createObjectURL(file);
        } else if (window.URL != undefined) { // mozilla(firefox)
        url = window.URL.createObjectURL(file);
        } else if (window.webkitURL != undefined) { // webkit or chrome
          url = window.webkitURL.createObjectURL(file);
        }
        return url;
    },
    decodeQrCode(file) {
      var that = this;
      var url = this.getObjectURL(file.raw);
      console.log(url);//这里能打印出来
      const qr = new QrCode()//这里报错
      qr.decodeFromImage(url).then(res=>{
        console.log(res.data)
      }).catch(err=>{
        console.log("识别失败,请重新上传")
      })
    },

img

请大家请指教,非常感谢

下载 nvm 安装2.x 的vue ,然后切换到2.x版本,你的版本不兼容