简体   繁体   English

在 Laravel 安装中通过 NPM 安装 Bootstrap

[英]Installing Bootstrap through NPM in Laravel install

I added Bootstrap in my package.json file like this "bootstrap": "^4.3.1" after that I typed npm install in the terminal and it completed without any errors.我在我的 package.json 文件中添加了 Bootstrap 像这样"bootstrap": "^4.3.1"之后我在终端中输入npm install并且它没有任何错误地完成。 What's next?下一步是什么? How can I add Bootstrap in my view?如何在我的视图中添加 Bootstrap? It seems that NPM installed Bootstrap to the /node_modules folder, but I also have the bootstrap.js file in resources/js/bootstrap.js.似乎 NPM 将 Bootstrap 安装到 /node_modules 文件夹,但我在 resources/js/bootstrap.js 中也有 bootstrap.js 文件。

you can use Laravel mix to the compile your assets and then simply link that in your layout, so what you need to is import bootstrap in your app.scss you can do it like this,你可以使用 Laravel mix 来编译你的资产,然后简单地将它链接到你的布局中,所以你需要的是在你的app.scss导入 bootstrap 你可以这样做,

@import '~bootstrap/scss/bootstrap';

and in you resources/views/layouts/app.blade.php link that style file like this,并在您的resources/views/layouts/app.blade.php链接该样式文件,如下所示,

<link href="{{ asset('css/app.css') }}" rel="stylesheet">

in laravel 5.6 or lesser versions app.scss file was located in resources/assets/sass but in laravel 5.7 and higher version it has been changed to resources/sass/ .在 Laravel 5.6 或更低版本中, app.scss文件位于resources/assets/sass但在 Laravel 5.7 及更高版本中,它已更改为resources/sass/ run npm run dev in your project folder to generate the assets.在项目文件夹中运行npm run dev以生成资产。 hope this helps希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM