【发布时间】:2020-06-04 08:28:28
【问题描述】:
我已经被这个问题困扰了将近 3 天了。所以我目前正在尝试做的是在将您带到 URL 的页面上显示 QR 码。为此,我使用ngx-qrcode2。
到目前为止,我已经尝试过运行npm install ngx-qrcode2 --save。然后,我按照本教程:https://www.youtube.com/watch?v=4bsrqHcb-hQ,甚至生成了另一个 Angular 应用程序,并完全按照他所做的。它仍然不起作用。运行后,我的控制台显示如下错误:
Uncaught Error: Template parse errors:
Can't bind to 'qrc-value' since it isn't a known property of 'ngx-qr-code'.
此外,在我一直致力于生成 QR 码的我自己的应用程序上,它不显示 QR 码,但不同之处在于它也不显示任何控制台错误。这与我尝试生成的 QR 码应用程序是分开的。
这是我的一些二维码生成应用的代码:
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'qra-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
value = 'http://www.google.com';
}
app.component.html
<h1>Visit this site.</h1>
<ngx-qr-code qrc-element-type="url" [qrc-value]="value"></ngx-qr-code>
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { NgxQRCodeModule } from 'ngx-qrcode2';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
NgxQRCodeModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
我的其他应用也有完全相同的东西。
另外,如果有帮助,这是我的 package.json 文件。
{
"name": "qrcode",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~7.2.0",
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/forms": "~7.2.0",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"core-js": "^2.5.4",
"ngx-qrcode2": "0.0.9",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.13.0",
"@angular/cli": "~7.3.8",
"@angular/compiler-cli": "~7.2.0",
"@angular/language-service": "~7.2.0",
"@types/node": "~8.9.4",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2"
}
}
此时,我不确定还能做什么。提前致谢。
【问题讨论】:
-
我认为这是您使用的标签不正确。假设是
而不是 . -
我也有同样的问题,你解决了吗?
标签: npm jhipster qr-code angular7