2017-09-13 28 views
1

我試圖使用primeng編輯器控制:https://www.primefaces.org/primeng/#/editorPrimeNg錯誤:奎爾沒有定義

但我得到的錯誤:

ERROR ReferenceError: Quill is not defined at Editor.webpackJsonp.../../../../primeng/components/editor/editor.js.Editor.ngAfterViewInit

我的項目使用:

  • Angi Cli:1.4.1
  • Angular:4.3.6
  • NPM:5.4.1
  • 節點:6.10.0
  • PrimeNG:4.2.0

我發現這個問題:https://github.com/primefaces/primeng/issues/807

我跟着指示:

導入編輯器模塊

import {EditorModule} from 'primeng/primeng'; 

安裝軟件包:

npm install quill --save 

npm install @types/quill --save 

更新角cli.json

"styles": [ "../node_modules/quill/dist/quill.core.css", "../node_modules/quill/dist/quill.snow.css", ], "scripts": [ "../node_modules/quill/dist/quill.js" ], 

但它仍然有同樣的問題。我只是添加默認的標記:

<p-editor [(ngModel)]="text" [style]="{'height':'320px'}"></p-editor> 

而我得到的錯誤,它看起來是這樣的:

enter image description here

在該線程我沒有嘗試的唯一的事情正在安裝的WebPack插件因爲我正在使用角度cli,我不認爲這是一個選項。

我該如何解決這個問題?

+0

你有什麼想法,它初始化這個控制測試? –

回答

2

試試這個:它的工作對我來說完全

版本:

Node : 7.9.0 
angular/cli: 1.3.0 
angular: 4.3.6 
npm: 4.2.0 
primeng": "^4.2.0-rc.1" 

安裝節點模塊鵝毛筆

npm install quill --save 

.angular-cli.json

"styles": [ 
    "../node_modules/primeng/resources/themes/omega/theme.css", 
    "../node_modules/primeng/resources/primeng.min.css", 
    "../node_modules/quill/dist/quill.core.css", 
    "../node_modules/quill/dist/quill.snow.css" 
], 
"scripts": [ 
    "../node_modules/quill/dist/quill.js" 
] 

app.module.ts

import { EditorModule } from 'primeng/primeng'; 

@NgModule({ 
    imports: [ 
     EditorModule 
    ] 
}) 

app.component.html

<p-editor [(ngModel)]="text" [style]="{'height':'320px'}"></p-editor> 

app.component。TS

export class AppComponent { 
    text: string; 
} 

+0

這看起來和我所做的一樣。我看不出差異 – Guerrilla

+0

您是否使用與我相同的版本? – Guerrilla

+0

更新版本我將用於檢查答案 – Chandru