Angular 2不导入Bootstrap CSS [英] Angular 2 doesn't import Bootstrap css

查看:103
本文介绍了Angular 2不导入Bootstrap CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直接来自 https://angular.io/docs/ts/latest/guide/forms.html

让我们添加样式表.

Let's add the stylesheet.

在应用程序根文件夹中打开一个终端窗口,然后输入命令:

Open a terminal window in the application root folder and enter the command:

npm install bootstrap --save

npm install bootstrap --save

打开index.html并将以下链接添加到标题.

Open index.html and add the following link to the head.

link rel ="stylesheet" href ="node_modules/bootstrap/dist/css/bootstrap.min.css">

link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">

但是,我不断收到404

However, i keep getting 404

获取 http://localhost:4200/node_modules/bootstrap/dist/css/bootstrap.min.css

当我使用在线地址添加脚本时,它可以工作,但是angular为什么找不到我的文件的路径?

It works when i add the script with the online address, but why does angular fails to find the path to my file?

推荐答案

index.htmlnode_modules在同一目录中时,它可以工作.

It is working when index.html is in the same directory as node_modules.

要从angular-CLI put中添加引导程序

To add bootstrap from angular-CLI put

'bootstrap/dist/**/*.+(js|css.map|css|eot|svg|ttf|woff|woff2)'

并运行ng build

这篇关于Angular 2不导入Bootstrap CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆