从 index.html 到 node_modules 文件夹的相对文件路径无效

Relative file path from index.html to node_modules folder not working

我无法 link访问我的 index.html 文件中 node_modules 文件夹中的文件(在 link 标签和脚本标签中)。我的项目基于 Angular2,我使用 Angular CLI 生成项目及其文件结构。

index.html 文件位于 src 文件夹中,该文件夹与包含我要 link 的文件的 node_modules 文件夹相邻。

目前我正在使用 ../ 返回文件夹的相对路径,但它不起作用,因为控制台给我 link 标签和 [= 中的两个脚本标签的错误23=]。

谁能帮我找到正确的文件路径?谢谢

screenshot of index.html

使用 angular-cli.json 文件包含 styles (<link>) 和 scripts (<script>) 到你的 index.html.

只需将 apps[0].scripts 用于 脚本 链接,同样地,将 apps[0].styles 用于 样式

另一种方法是将样式表直接包含到 src/ 目录中的 styles.css/scss/less 文件中。