如何在Angular 2中创建导入QuillJS模块的组件? [英] How do I create a component in Angular 2 that imports the QuillJS module?

查看:74
本文介绍了如何在Angular 2中创建导入QuillJS模块的组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Angular 2和TypeScript还是很陌生.我正在使用AngularCLI和NPM创建我的Angular项目.我已经使用NPM将主轴节点模块安装到我的项目中.我现在正在尝试创建一个组件,在其中可以通过其API自定义笔管编辑器.

I am fairly new to Angular 2 and TypeScript. I am using AngularCLI and NPM to create my Angular Project. I have used NPM to install the quill node module into my project. I am now trying to create a component in which I can customize my quill editor through their API.

我正在尝试使用:

import * as Quill from 'quill'; 

这将返回找不到羽毛笔模块"错误.

This is returning a 'cannot find quill module' error.

我已经添加了

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

将package.json作为依赖项.

to package.json as dependencies.

推荐答案

我试图在用 ng new 命令生成的pet Angular CLI项目中重现您的问题,并且工作正常.这是代码:

I tried to reproduce your issue in a pet Angular CLI project generated with the ng new command, and it worked fine. Here is the code:

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);
  }
}

这是我得到的输出:图片链接

转到项目的 node_modules 文件夹并查找名为 quill 的文件夹,即使存在,也要删除 node_modules 文件夹然后再次运行 npm i 命令

Go to you project's node_modules folder and look for a folder named quill, anyway, even if it is there, delete the node_modules folder and run npm i command again

这篇关于如何在Angular 2中创建导入QuillJS模块的组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆