【问题标题】:Why does Angular CLI scripts property not work for CKEditor?为什么 Angular CLI 脚本属性不适用于 CKEditor?
【发布时间】:2017-04-30 16:02:37
【问题描述】:

在我的 Angular[24] 应用程序中,我使用的是 ng2-ckeditor。为了使它工作,我必须将以下内容添加到我的 index.html 文件中:

<script src="./assets/js/ckeditor/ckeditor.js"></script>

(由于似乎没有 npm 包来安装编辑器本身,所以我下载了当前的 zip 文件并将其解压缩到 ./assets/js 中。)

读取documentation 这应该包含在 scripts 属性中的 .angular-cli.json 文件中,如下所示:

(snip)  
"styles": [
    "../node_modules/bootstrap/dist/css/bootstrap.css",
    "styles.css"
  ],
  "scripts": [
    "./assets/js/ckeditor/ckeditor.js"
  ],
  "environmentSource": "environments/environment.ts",
  (snip)

但如果我删除上面的 HTML 标记并这样做,它就不起作用。

这是否应该通过 JSON 文件完成?如果是,我会做错什么?

【问题讨论】:

  • 没听懂你的意思。有 npm 包。 npmjs.com/package/ng2-ckeditor。对于脚本,您必须在 angular-cli.json 中编写它。那么你所要做的就是在模板中使用它``
  • 这应该可以正常工作。您使用的是哪个版本的 cli?
  • @ParthGhiya 查看 ng2-ckeditor 的文档。它说要在 index.html 文件中安装以下内容:
  • @alan:你会在节点模块文件夹中找到它
  • 你有没有在你的资产文件夹中得到这个工作?我正在运行需要我们在资产路径中使用静态版本的自定义。升级到 Angular-CLI 和 Angular 6 后,加载时出现问题。如果是这样,您的解决方案是什么?

标签: angular


【解决方案1】:
  1. npm install ckeditor --save
    
  2. 改变你的 .angular-cli.json

    "scripts": [
     "../node_modules/ckeditor/ckeditor.js"
    ],
    

【讨论】:

  • 这部分似乎可以工作,但我仍然有一些问题太复杂,无法在此处列出。我将不得不输入一个新问题。我收到控制台日志消息,表明它无法加载资源。
猜你喜欢
  • 1970-01-01
  • 2020-03-09
  • 1970-01-01
  • 2022-08-07
  • 2011-09-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多