我第一次学习laravel 5.2约一周。我试图从YouTube和文件laravel学习larevel。但我不知道他们教,只是复制模板bootstrap没有下载引导文件放入文件夹公共它的作品,但当我试图按照主题它不适合我,但是当我下载引导文件并放入公用文件夹,然后调用它。我的问题我想知道bootstrap如何在laravel中正常工作。引导程序如何在laravel 5中正确工作?
1
A
回答
1
您只需创建刀片模板,然后在模板中放置引导程序的链接。
实施例(index.blade.php)CDN链接:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Title</title>
<!-- Bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<!-- Here you can put your content -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</body>
</html>
实施例(index.blade.php)本地链路:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Title</title>
<!-- Bootstrap -->
<link href="http://yoursite/public/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<!-- Here you can put your content-->
<script src="http://yoursite/public/assets/bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
-1
Laravel是一个服务器端的框架。它应该处理数据库,缓存,日志和验证。 Bootstrap是一个客户端UI框架。它应该处理UI组件,如选项卡,网格,表单和一些排版方面。
每个服务器端框架都支持每个客户端框架,所以随意使用Laravel和Bootstrap。
特别是你应该创建一个基本的布局与一些常见的HTML并扩展它在你的不同视图。在这个基础布局中,您必须包含通过CDN的Bootstrap或使用asset()助手本地化。该帮助程序可帮助您构建网址(https://laravel.com/docs/5.2/helpers)。
+0
谢谢兄弟回答 – He7nG
0
Another way to get that done is to get bootstrap from npm if you prefer working offline, plus laravel 5 comes with gulp and a package.json file by default
1. add the following to your package to json
{
"private": true,
"dependencies": {
"gulp": "^3.8.8",
"laravel-elixir": "^2.0.0",
"jquery": "latest",
"bootstrap": "latest"
}
}
2. npm install that would get the latest verion of bootstrap and jquery which is required, if you encounter any error if on linux do sudo npm install
3. mix the css and javascript file with laravel elixir by have below declarations in your gulpfile.js
var elixir = require('laravel-elixir');
var nodeDir = './node_modules/';
/*
|--------------------------------------------------------------------------
| Elixir Asset Management
|--------------------------------------------------------------------------
|
| Elixir provides a clean, fluent API for defining some basic Gulp tasks
| for your Laravel application. By default, we are compiling the Sass
| file for our application, as well as publishing vendor resources.
|
*/
elixir(function(mix) {
//mix css first and copy the needed fonts
//mix.css('app.css', 'public/css',)
mix.styles([
'bootstrap/dist/css/bootstrap.css',
'font-awesome/css/font-awesome.css'
], './public/css/app.css', nodeDir)
.copy(nodeDir + 'font-awesome/fonts', 'public/fonts')
.copy(nodeDir + 'bootstrap/fonts', 'public/fonts');
//mix javascript
mix.scripts([
'jquery/dist/jquery.js',
'bootstrap/dist/js/bootstrap.js'
], './public/js/app.js', nodeDir);
});
run gulp
$ gulp
finally a welcome.blade.php
<!DOCTYPE html>
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="https://getbootstrap.com/favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="{{asset('css/app.css')}}">
<title>Fixed Top Navbar Example for Bootstrap</title>
</head>
<body cz-shortcut-listen="true">
<div id="app"></div>
<script src="{{asset('js/app.js')}}"></script>
</body>
</html>
The above reduces number of http request you make to load bootstrap bootstrap and its dependency jquery
reference : https://laravel.com/docs/5.0/elixir
Hope this helps
相关问题
- 1. URL ::如何在laravel 5中工作?
- 2. 引导程序中的一列如何不能正常工作?
- 3. 引导导航栏工作不正确
- 4. N1引导程序如何工作
- 5. 如何正确引导中
- 6. 如何让Laravel 5在Heroku上工作?
- 7. 如何应用Laravel 5教程中的基本引导样式?
- 8. 无法在引导程序3中使药丸正常工作
- 9. 如何在引导程序中删除Portlet的工作原理?
- 10. 如何让媒体查询在引导程序中工作?
- 11. 如何让引导类在reactjs应用程序中工作?
- 12. 引导程序如何工作,尤其是在Zend Framework中?
- 13. 引导程序下拉不正确
- 14. 这个程序集引导程序代码如何工作?
- 15. Python导入如何正确工作?
- 16. Laravel 5 - 会话不能正常工作
- 17. Laravel 5 Eager Loading无法正常工作
- 18. Laravel 5路线不能正常工作
- 19. Laravel 5 mewebstudio/captcha无法正常工作
- 20. Laravel 5响应不正确
- 21. 如何在laravel 5中启动服务提供程序5
- 22. 如何在引导程序对话框上正确触发默认操作?
- 23. 如何在Laravel 5.2中编辑引导程序css文件
- 24. 如何在Laravel 5.4中使用引导程序4?
- 25. 如何在laravel模板中使用引导程序
- 26. 如何在Laravel 5中正确命名模型?
- 27. 远程引导程序typeahead不工作
- 28. 引导程序中的固定列无法正常工作
- 29. 引导程序Nav连接未打开或正在工作
- 30. Laravel 4引导程序错误
我不认为使用localhost的绝对URL作为域是一个很好的解决方案。 –
谢谢兄弟好的解释 – He7nG
这是我的荣幸;) –