我正在尝试生成二维码并在 ionic 组件中显示它。我尝试了以下库 https://www.npmjs.com/package/ngx-qrcode2
但它似乎没有正确识别元素。我试过:
<ngx-qrcode
[qrc-value] = "value"
</ngx-qrcode>
还有:
<ngx-qrcode
[elementType]="elementType"
[value] = "value"
cssClass = "aclass"
errorCorrectionLevel = "L">
运行时出现以下错误:
ERROR Error: Uncaught (in promise): Error: Template parse errors: Can't bind to 'value' since it isn't a known property of 'ngx-qrcode'.
- If 'ngx-qrcode' is an Angular component and it has 'value' input, then verify that it is part of this module.
- If 'ngx-qrcode' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
- To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. (" <ngx-qrcode [ERROR ->][value]="value">
我知道这个库现在已经被弃用了,所以我试过了 https://www.npmjs.com/package/@techiediaries/ngx-qrcode
类似的结果:
库在组件模块中导入如下:
import { UbicacionPageRoutingModule } from './ubicacion-routing.module';
import { UbicacionPage } from './ubicacion.page';
import { UbicacionAltaComponent } from './ubicacion-alta/ubicacion-alta.component';
import { NgxQRCodeModule } from '@techiediaries/ngx-qrcode';
import { VerQrUbicacionModalComponent } from './ver-qr-ubicacion-modal/ver-qr-ubicacion-modal.component';
@NgModule({
entryComponents: [UbicacionAltaComponent, VerQrUbicacionModalComponent],
imports: [
CommonModule,
FormsModule,
IonicModule,
UbicacionPageRoutingModule,
NgxQRCodeModule
],
declarations: [UbicacionPage, VerQrUbicacionModalComponent],
exports: [ UbicacionAltaComponent, VerQrUbicacionModalComponent]
})
export class UbicacionPageModule {}
最佳答案
- 使用 ngx-qrcode 而不是 ngx-qrcode2(已弃用)
- 确保您已导入App Module 和您的Component Module
关于angular - 在无法识别的 ionic 5 错误元素中显示二维码 ngx-qrcode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63018176/