如何在Angular 2中创建一个导入QuillJS模块的组件?

4

我是一个对Angular 2和TypeScript比较新的人。我正在使用AngularCLI和NPM创建我的Angular项目。我已经使用NPM将quill节点模块安装到我的项目中。现在,我正在尝试创建一个组件,在该组件中,我可以通过其API自定义我的quill编辑器。

我正在尝试使用:

import * as Quill from 'quill'; 

这里返回了“找不到quill模块”的错误。
我已经添加了


"": "0.0.26",
"quill": "^1.0.4",

将其添加到package.json文件的dependencies中。


尝试使用 import * as quill from 'quill'; 替代。可能存在大小写问题。 - Prav
1个回答

4

我尝试在使用ng new命令生成的示例Angular CLI项目中重现您的问题,结果正常。以下是代码:

import { Component } from '@angular/core';
import * as Quill from 'quill';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app works!';

  ngOnInit() {
    console.log(Quill);
  }
}

And here's the output I get: Image Link

前往你的项目中的 node_modules 文件夹并查找名为 quill 的文件夹,无论如何,即使它存在,也请删除 node_modules 文件夹并再次运行 npm i 命令。


删除 node_modules 然后运行 npm i 就好了!谢谢! - Farhan Islam

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接