我使用我的角4服務器端渲染應用simpleMDE編輯器並獲得textarea的參考使用的ReferenceError:導航不angular4與服務器端渲染
@ViewChild('simpleMDE') textarea : ElementRef;
和ngAfterViewInit初始化它定義()
this.simplemde = new SimpleMDE(
{
element: this.textarea.nativeElement.value,
})
在模板
在正在使用的textarea這樣
<textarea id="simpleMDE" #simpleMDE></textarea>
雖然啓動服務器其投擲錯誤說
projectpath\node_modules\codemirror\lib\codemirror.js:11
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
^
ReferenceError: navigator is not defined
at projectpath\node_modules\codemirror\lib\codemirror.js:18:17
請建議的東西,我卡在這裏。 GitHub Repo
我沒有在手工代碼中的任何地方使用它,但simpleMDE texteditor在內部使用它,所以可能從那裏引發它的拋出錯誤。 只要我會回到我的機器,我會盡快解決您的問題。 感謝男人.... !! –
@PraveenRana請參閱編輯答案,不確定是否有助於解決問題。 –
好的,Parth。我會測試這段代碼,並讓你知道這是否有效。 只能在晚上測試。 –