我已经使用 cli 安装了 ng2-ckeditor :
npm install ng2-ckeditor --save
然后将 CKEditor javascript 文件包含在我的索引文件中:
<script src="https://cdn.ckeditor.com/4.5.11/full/ckeditor.js"></script>
然后在模块文件中导入模块:
import { CKEditorModule } from 'ng2-ckeditor';
在导入“CKEditorModule”中
并尝试在html中使用
它显示错误:
错误于
/var/www/html/eventswebsite/frontendapp/node_modules/ng2-ckeditor/lib/ckeditor.component.d.ts
(43,26):找不到名称“对象”。
“ng2-ckeditor/lib/ckeditor.component.d.ts (43,26):找不到名称
'目的'。”
如果我改变它就会起作用
ckeditorInit(配置:对象)
To
ckeditorInit(配置:任意)
在 npm 模块 ckeditor 组件文件中。
我为那些面临此错误“无法找到名称'对象'”的人发布此答案,无论他们在哪个组件中遇到此错误。这是与 tsc 编译器版本相关的问题。 “object”是 TS2.2 中的关键字。
我正在使用 VS 2017 社区。默认情况下,它附带 tsc 1.5 ie。打字稿编译器版本 1.5。我尝试从 Nuget 更新它,并安装了“Typescript for VS 2017”,但没有任何帮助,即使我的计算机有最新版本的 TypeScript,但 VS TypeScript 版本仍然是 1.5。
然后我搜索了微软最新的VS 2017更新,幸运的是我在VS的顶部栏找到了最新版本的通知。安装最新更新后,我在 VS 上的 typescript 版本更新为 2.2。这解决了问题并且编译错误消失了。
As a side note, you can find the version of typescript VS is using under menu "Help\About Microsoft Visual Studio", then on pop up screen scroll down a bit as shown in below image:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)