use*_*060 6 php laravel laravel-4
我是一个Laravel新手.我刚刚安装了一些第三方软件包,我想将Twitter引导程序集成到我的脚本中.有没有办法做到这一点,没有进入每个包并将代码添加到每个视图的刀片模板?
Alm*_*itt 40
航站楼内:
laravel new project
cd project
composer require laravel/ui
php artisan ui bootstrap
npm install && npm run dev
Run Code Online (Sandbox Code Playgroud)
然后,在您正在处理的 HTML 中,同时引入 CSS 和 JavaScript:
<!doctype html>
<html lang="en">
<head>
...
<link href="/css/app.css" rel="stylesheet">
</head>
<body>
....
<script src="/js/app.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
@Svyat,希望这也能回答您的问题。
快乐编码:)
我意识到这是旧的......但它是我在谷歌上出现的最佳结果。希望这会在将来对某人有所帮助。
如果您使用的是Laravel 6.2,
航站楼内:
npm install bootstrap
Run Code Online (Sandbox Code Playgroud)
在 app.scss 中:
@import "node_modules/bootstrap/scss/bootstrap";
Run Code Online (Sandbox Code Playgroud)
在终端中,运行以下命令以生成 /public/css/app.css 文件:
npm run dev
Run Code Online (Sandbox Code Playgroud)
在welcome.blade.php 中:
<link rel="stylesheet" href="/css/app.css">
Run Code Online (Sandbox Code Playgroud)
快乐编码
这是我当前运行的应用程序主布局的顶部/标题部分:
<!-- app/views/layouts/master.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.0" />
<meta name="description" content="Simple CMS" />
<meta name="author" content="Sheikh Heera" />
<link rel="shortcut icon" href={{ assets("favicon.png") }} />
<title>LaraPress</title>
<!-- Bootstrap core CSS -->
<link href = {{ asset("bootstrap/css/bootstrap.css") }} rel="stylesheet" />
<!-- Custom styles for this template -->
<link href = {{ asset("bootstrap/css/sticky-footer-navbar.css") }} rel="stylesheet" />
<!-- Optional theme -->
<link rel="stylesheet" href="{{ asset('bootstrap/css/bootstrap-theme.min.css') }}">
</head>
Run Code Online (Sandbox Code Playgroud)
按照这种方法,使您的每个视图扩展主布局,如下所示:
<!-- app/views/user/show.blade.php -->
@extends('layouts.master')
@section('content')
<div class="panel panel-default">
<div class="panel-heading"><label>View User</label>
<a class ='pull-right' href="{{ Request::header('referer') }}">
<i class="glyphicon glyphicon-circle-arrow-left"></i> Go Back
</a>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的部分视图(顶部),它扩展了主布局,使其成为主布局的一部分.主布局存储在app/views/layouts/文件夹中,名称是master.blade.php这样的,@ extends('layouts.master')表示master.blade.php从layouts文件夹扩展而它(名称)可以是任何东西,每个视图也必须包含.blade在文件名之前.php.