首页 > 解决方案 > After Installing @zxing/library in ionic3, There is an error. How Can I solve?

问题描述

I'd like to solve the error about using BrowserQRCodeReader from @zxing/library

I'm using TypeScript version 3.4.5 and ionic3.
I installed the plugin typing $npm i @zxing/library --save and applied it to the code I am writing and I get an error. I want to know the cause of the error and how to solve it. Here's the code I wrote.

import { Component } from '@angular/core';
import { BrowserQRCodeReader } from '@zxing/library';

...
...
...

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

...
...
...
 target_wallet_address: string;
...
...
...

decode(){
const codeReader = new BrowserQRCodeReader()
codeReader.decodeFromImage(undefined,this.imagePath)
.then((result) => {
  console.log("success")
  this.target_wallet_address = result.getText();
}).catch((err) => {
  console.error(err)
})

}//end decode

...
...
...

Here's the message and there's no display.

Initializers are not allowed in ambient contexts.

I wanted to get a specific layout, but I could not.

p.s. I added a screenshot file about the error message.

标签: angulartypescriptionic-frameworkionic3

解决方案


推荐阅读