当我试图用Angular 8中的quill editor组件注册quill better表时,如何修复我遇到的这个错误?
我不熟悉棱角形,并尝试在羽毛笔编辑器中设置表格。每当我尝试注册quill better table模块时。我面临重大问题。请看下面我的代码当我试图用Angular 8中的quill editor组件注册quill better表时,如何修复我遇到的这个错误?,angular,quill,ngx-quill,Angular,Quill,Ngx Quill,我不熟悉棱角形,并尝试在羽毛笔编辑器中设置表格。每当我尝试注册quill better table模块时。我面临重大问题。请看下面我的代码 import { Component , ViewChild, OnInit} from '@angular/core'; import QuillBetterTable from 'quill-better-table'; import Quill from 'quill'; import { QuillEditorComponent } from 'ng
import { Component , ViewChild, OnInit} from '@angular/core';
import QuillBetterTable from 'quill-better-table';
import Quill from 'quill';
import { QuillEditorComponent } from 'ngx-quill';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit{
@ViewChild(QuillEditorComponent, { static: true }) editor: QuillEditorComponent
content = 'Hello World!'
modules = {};
ngOnInit(){
Quill.register({
'modules/better-table': QuillBetterTable
});
}
constructor()
{
this.modules = {
table: false, // disable table module
'better-table': {
operationMenu: {
items: {
unmergeCells: {
text: 'Another unmerge cells name'
}
},
color: {
colors: ['green', 'red', 'yellow', 'blue', 'white'],
text: 'Background Colors:'
}
}
},
keyboard: {
bindings: QuillBetterTable.keyboardBindings
}
}
}
}
我收到这些错误-
quill Cannot import modules/table. Are you sure it was registered?
debug @ quill.js:2037
quill.js:2037 quill Cannot load table module. Are you sure you registered it?
我假设您已经配置了angular project。如果没有,则可以使用此命令创建新的角度项目npx@angular/cli@next新编辑 使用纱线/npm将quill.js包添加到angular项目中。 >npm安装quill@dev羽毛笔更好的桌子ngx羽毛笔 安装后,项目的package.json应该具有以下依赖项
"dependencies": {
"ngx-quill": "^7.3.9",
"quill": "^2.0.0-dev.3 ",
"quill-better-table": "^1.2.4",
}
导入quill.js snow主题或任何其他主题。在文件src/styles.scss中,添加此代码段
@导入~quill/dist/quill.snow.css;
导入和配置纬管模块
文件:src/app/app.module.ts
从@angular/core导入{NgModule};
从@angular/platform browser导入{BrowserModule};
从ngx quill导入{QuillConfig,QuillModule};
从纬管导入*作为纬管;
进口羽毛笔从羽毛笔更好的表;
从./app.component导入{AppComponent};
羽毛套
{
模块/更好的表格:QuillBetterTable
},
符合事实的
;
常量quillConfig:quillConfig={
模块:{
table:false,//禁用表模块
更好的表格:{
操作菜单:{
项目:{
未合并单元格:{
text:另一个未合并的单元格名称
}
},
颜色:{
颜色:[fff,红色,rgb0,0,0],//操作菜单中的颜色
文本:背景色//字幕
}
}
},
键盘:{
绑定:QuillBetterTable.keyboardBindings
}
}
};
@NGD模块{
声明:[AppComponent],
导入:[BrowserModule,QuillModule.forRootquillConfig],
提供者:[],
引导:[AppComponent]
}
导出类AppModule{}
添加HTML标记。
文件:src/app/app.component.html
在编辑器中插入表格
文件:src/app/app.component.ts
从@angular/core导入{ChangeDetectionStrategy,Component};
接口套筒{
getModulemoduleName:字符串;
}
接口优化表模块{
insertTablerows:number,columns:number:void;
}
@组成部分{
选择器:应用程序根,
templateUrl:./app.component.html,
样式URL:[./app.component.scss],
changeDetection:ChangeDetectionStrategy.OnPush
}
导出类AppComponent{
公共羽毛笔:羽毛笔;
私有get tableModule:BetterTableModule{
返回this.quill.getModulebetter-table;
}
public editorcreatevent:Quill:void{
this.quill=事件;
//有关如何将新表添加到编辑器的示例
这个是可添加的;
}
私有addNewtable:void{
this.tableModule.insertTable3,3;
}
}
这是输出最后的样子:
我假设您已经配置了角度项目。如果没有,则可以使用此命令创建新的角度项目npx@angular/cli@next新编辑 使用纱线/npm将quill.js包添加到angular项目中。 >npm安装quill@dev羽毛笔更好的桌子ngx羽毛笔 安装后,项目的package.json应该具有以下依赖项
"dependencies": {
"ngx-quill": "^7.3.9",
"quill": "^2.0.0-dev.3 ",
"quill-better-table": "^1.2.4",
}
导入quill.js snow主题或任何其他主题。在文件src/styles.scss中,添加此代码段
@导入~quill/dist/quill.snow.css;
导入和配置纬管模块
文件:src/app/app.module.ts
从@angular/core导入{NgModule};
从@angular/platform browser导入{BrowserModule};
从ngx quill导入{QuillConfig,QuillModule};
从纬管导入*作为纬管;
进口羽毛笔从羽毛笔更好的表;
从./app.component导入{AppComponent};
羽毛套
{
模块/更好的表格:QuillBetterTable
},
符合事实的
;
常量quillConfig:quillConfig={
模块:{
table:false,//禁用表模块
更好的表格:{
操作菜单:{
项目:{
未合并单元格:{
text:另一个未合并的单元格名称
}
},
颜色:{
颜色:[fff,红色,rgb0,0,0],//操作菜单中的颜色
文本:背景色//字幕
}
}
},
键盘:{
绑定:QuillBetterTable.keyboardBindings
}
}
};
@NGD模块{
声明:[AppComponent],
导入:[BrowserModule,QuillModule.forRootquillConfig],
提供者:[],
引导:[AppComponent]
}
导出类AppModule{}
添加HTML标记。
文件:src/app/app.component.html
在编辑器中插入表格
文件:src/app/app.component.ts
从@angular/core导入{ChangeDetectionStrategy,Component};
接口套筒{
getModulemoduleName:字符串;
}
接口优化表模块{
insertTablerows:number,columns:number:void;
}
@组成部分{
选择器:应用程序根,
templateUrl:./app.component.html,
样式URL:[./app.component.scss],
changeDetection:ChangeDetectionStrategy.OnPush
}
导出类AppComponent{
公共羽毛笔:羽毛笔;
私有get tableModule:BetterTableModule{
返回this.quill.getModulebetter-table;
}
public editorcreatevent:Quill:void{
this.quill=事件;
//埃克萨
关于如何向编辑器添加新表的示例
这个是可添加的;
}
私有addNewtable:void{
this.tableModule.insertTable3,3;
}
}
这是输出最后的样子:
每次我添加该行表格时:false,我仍然会收到错误信息,即-无法导入模块/表格。你确定它是注册的吗?当我删除这一行时,我仍然会得到一个永久的错误TypeError:无法读取新的quill_better_table_bettertable上未定义的属性'pop'。你能使用npx@angular创建一个单独的Angle应用程序吗/cli@next新的编辑器命令,并完全按照上面的所有步骤操作?是的,它与您的代码配合得很好,但我觉得这个模块还处于初级阶段,不能用于生产,几乎没有bug,你可以删除所有的单元格,但仍然只能使用一个,这太糟糕了。不管怎样,谢谢,你的想法很有帮助。我实现了它。当我打开一张表格,经过一张桌子时,它就起作用了。然而,一旦数据被插入数据库,当我打开表单进行编辑时,它不会在框中显示数据。其他人也面临同样的问题:你能检查一下这是否需要一个角度框架吗?它可以在没有角度限制的情况下进行设置吗?我一直在努力做到这一点。每次我添加行tables:false时,我仍然会得到一个错误,即无法导入模块/表。你确定它是注册的吗?当我删除这一行时,我仍然会得到一个永久的错误TypeError:无法读取新的quill_better_table_bettertable上未定义的属性'pop'。你能使用npx@angular创建一个单独的Angle应用程序吗/cli@next新的编辑器命令,并完全按照上面的所有步骤操作?是的,它与您的代码配合得很好,但我觉得这个模块还处于初级阶段,不能用于生产,几乎没有bug,你可以删除所有的单元格,但仍然只能使用一个,这太糟糕了。不管怎样,谢谢,你的想法很有帮助。我实现了它。当我打开一张表格,经过一张桌子时,它就起作用了。然而,一旦数据被插入数据库,当我打开表单进行编辑时,它不会在框中显示数据。其他人也面临同样的问题:你能检查一下这是否需要一个角度框架吗?它可以在没有角度限制的情况下进行设置吗?我正在努力做到这一点。