error NG8001: 'qr-code' is not a known element:

解决方案

假如你的组件模块叫做a-demo.module,你的组件叫做print.component.ts

检查使用方法,在当前组件的模块里引入

src\app\routes\a-demo\a-demo.module.ts

import { NgModule } from '@angular/core';
import { QRCodeModule } from 'angular2-qrcode'; ... @NgModule({
imports: [
QRCodeModule,
...
]
})

使用方法

src\app\routes\a-demo\print\print.component.ts

<div>
<qr-code [value]="'All QR Code data goes here!'" [size]="150"></qr-code>
</div>

如果还报错,检查你的组件是否在当前模块的路由以及模块都进行注册了

src\app\routes\a-demo\a-demo-routing.module.ts

import { NgModule, Type } from '@angular/core';
import { QRCodeModule } from 'angular2-qrcode'; import { ADemoRoutingModule } from './a-demo-routing.module';
import { PrintComponent } from './print/print.component'; // 重点观察这一个代码,你有没有写 const COMPONENTS: Array<Type<void>> = [PrintComponent]; // 重点观察这一个代码,你有没有写 @NgModule({
imports: [QRCodeModule, ADemoRoutingModule],
declarations: COMPONENTS
})
export class ADemoModule { }

OK了

angular2-qrcode 引用报错 error NG8001: 'qr-code' is not a known element:的更多相关文章

  1. [ios] 定位报错Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"

    Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error ...

  2. linux使用wkhtmltopdf报错error while loading shared libraries:

    官网提示 linux需要这些动态库.depends on: zlib, fontconfig, freetype, X11 libs (libX11, libXext, libXrender) 在li ...

  3. 发布报错:Error ITMS-90635 - Invalid Mach-O in bundle - submitting to App store

    发布报错:Error ITMS-90635 - Invalid Mach-O in bundle - submitting to App store 昨晚上传项目到AppStore,报了这个错,纳尼! ...

  4. spring jpa 实体互相引用返回restful数据循环引用报错的问题

    spring jpa 实体互相引用返回restful数据循环引用报错的问题 Java实体里两个对象有关联关系,互相引用,比如,在一对多的关联关系里 Problem对象,引用了标签列表ProblemLa ...

  5. 升级到macOS 10.12 mysqlb报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

    系统升级到macOS 10.12后启动mysql后,在终端输入mysql 报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' ...

  6. inoic start projectname sidemenu报错 - Error: Cannot find module 'lodash._baseslice'

    inoic start projectname sidemenu报错 - Error: Cannot find module 'lodash._baseslice' 在公司的电脑上出现过这个错误,后来 ...

  7. 运行编译后的程序报错 error while loading shared libraries: lib*.so: cannot open shared object file: No such file or directory

    运行编译后的程序报错  error while loading shared libraries: lib*.so: cannot open shared object file: No such f ...

  8. CentOS命令登录MySQL时,报错ERROR 1045 (28000):

    CentOS命令登录MySQL时,报错ERROR 1045 (28000): Access denied for user root@localhost (using password: NO)错误解 ...

  9. android sdk启动报错error: could not install *smartsocket* listener: cannot bind to 127.0.0.1:5037:

    android sdk启动报错error: could not install *smartsocket* listener: cannot bind to 127.0.0.1:5037: 问题原因: ...

随机推荐

  1. 10.异步mysql

    python中操作mysql连接.操作.断开都是网络IO #安装支持异步aiomysql的模块 pip3 install aiomysql async def execute(): # 网络IO操作, ...

  2. HAProxy反向代理实例

    1.环境准备: 设备 IP地址 作用 系统版本 web1 10.0.0.18 Nginx-Web服务器 Rocky8.6 web2 10.0.0.28 Nginx-Web服务器 Rocky8.6 Ha ...

  3. <二>掌握构造函数和析构函数

    构造函数 和类名相同,可以带参数,参数可以有多个 构造函数执行完成后,内存开辟完成,同时可以完成初始化工作. 析构函数 ~Test(); 析构函数可以自己调用,析构函数调用后,对象不存在了.自己调了析 ...

  4. 2022春每日一题:Day 32

    题目:[USACO12DEC]First! G 不太记得当时怎么想的了,但是显然,当一个字符串的前缀存在则他一定不是first,然后做法:对于每个字符串,把每个字符结尾跟他有相同前缀的单词的同元素建边 ...

  5. 自学 TypeScript 第二天 编译选项

    前言: 昨天我们学习了 TS 的数据类型,不知道大家回去以后练习没练习,如果你练习了一定会发现一个问题,我们的 TS 好像和 JS 不太一样 JS 写完之后直接就可以放到页面上,就可以用了,而我们的 ...

  6. Go语言核心36讲36

    在前面,我几乎已经把Go语言自带的同步工具全盘托出了.你是否已经听懂了会用了呢? 无论怎样,我都希望你能够多多练习.多多使用.它们和Go语言独有的并发编程方式并不冲突,相反,配合起来使用,绝对能达到& ...

  7. 注册IBMlinuxone并使用xshell登陆

    登陆地址:https://linuxone.cloud.marist.edu/#/login 注册地址:https://linuxone.cloud.marist.edu/#/register?fla ...

  8. 抓包整理————ip 协议四[十五]

    前言 简单了解一下ip 协议选路问题. 正文 比如host1 到 host2是直接传输,因为host1和 host2 是同一交换机,直接arp表知道对方的mac. 第二种是他们是不同网段之间通信. 第 ...

  9. 用最少的代码模拟gRPC四种消息交换模式

    我们知道,建立在HTTP2/3之上的gRPC具有四种基本的通信模式或者消息交换模式(MEP: Message Exchange Pattern),即Unary.Server Stream.Client ...

  10. 如何利用C++使Windows蓝屏

    如何利用C++使Windows蓝屏 虽说windows非常强大,但是使它蓝屏也非常简单: 如果你想让Windows蓝屏,你一定会在运行框里输入: cmd /c for /f %I in ('wmic ...