php - 如何在 Laravel 刀片引擎的另一个视图中插入视图
问题描述
如何在 laravel 刀片引擎的另一个视图中插入视图刀片
我正在一个包含以下项目的项目中工作:主页视图......“ home.blade.php ”
我想添加另一个页面“ home2.blade.php ”
所以最后我得到了 1 页,它是“ home.blade.php ”,但它包含“ home2.blade.php ”
这是 home2.blade.php
@extends('layouts.app')
@section('content')
<!-- All Posts -->
@if(count($posts) > 0)
<div class="panel panel-default">
<div class="panel-heading">
All Posts
</div>
<div class="panel-body">
<table class="table table-striped task-table">
<!-- Table Headings -->
<thead>
<th>Title</th>
<th>Content</th>
</thead>
<!-- Table Body -->
<tbody>
@foreach($posts as $post)
<tr>
<td class="table-text">
<div>{{$post->title}}</div>
</td>
<td class="table-text">
<div>{{$post->content}}</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@endif
@endsection
这是“ home.blade.php ”
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body data-spy="scroll" data-offset="0" data-target="#navigation">
<!-- Fixed navbar -->
<div id="navigation" class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse"
data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
解决方案
include()
在 home.blade.php 中使用
例如:如果您的 home2 位于resources/views/
@include('home2')
推荐阅读
- html - 是否可以使用 CSS 更改插入符号“bubble”/“drop”颜色?(特定手机)
- sql - 计数组合+频率
- python - SOS 游戏 tkinter 问题,检查确认 SOS 已在列表范围内进行
- sql - 这个 SQL 查询可能吗?我正在尝试获取此表中出现频率最低的名称
- rust-cargo - Rust Crate:定义可配置变量
- python - 为什么我的错误是说我试图调用的属性不存在?
- reactjs - 初始化前无法访问“transactionId”
- android - 如何将 Firebase Recycler 视图从最新(列表顶部)排序到最旧
- python-3.x - 如何使用 pytest 测试 except 块的副作用?
- python - TypeError:Ui_MainWindow.on_click() 缺少 1 个必需的位置参数:“按下”