SO中文参考
首页
(current)
程序语言
c
java
python
c++
go
javascript
swift
c#
操作系统
linux
ubuntu
centos
unix
数据库
oracle
mysql
mongodb
postgresql
框架
node.js
angular
react-native
avalon
django
twisted
hadoop
.net
移动开发
android
ios
搜索
类比Laravel的[@extends @yield]和JS的[导出导入]@yield('标题')<...</desc> <question vote="0"> <p>我对 Laravel 布局的理解是:<br/> main.blade.php 将<strong>导入</strong>带有@yield的部分代码:</p> <pre><code><!-- main.blade.php --> <html> <head> <title>@yield('title')</title> </head> <body> @yield('content') </body> </html> </code></pre> <p>部分代码将<strong>导出</strong>自身到特定文件:</p> <pre><code><!-- partial.blade.php --> @extends('layouts.main') @section('title', 'Page Title') @section('content') <p>This is the content of the page.</p> @endsection </code></pre> <p>如果我理解正确的话,是部分本身决定去哪里? <br/> 如果是这样,我就头疼了...我不明白其中的逻辑。<br/> 如果多个视图想要使用相同的部分会发生什么?为什么不是反过来(<pre><code>@yield('layouts.partial','title')</code></pre>),就像在 JS 中一样,导入部分的表示它的路径?</p> </question> <answer tick="false" vote="0"> <p>我认为你的想法是错误的。部分或组件不会扩展布局。它们按原样通过 <pre><code>@component('components.modal')</code></pre> 或 <pre><code>@include('partials.paginate')</code></pre> 包含在内。</p> <p>你这里有什么:</p> <pre><code><!-- partial.blade.php --> @extends('layouts.main') @section('title', 'Page Title') @section('content') <p>This is the content of the page.</p> @endsection </code></pre> <p>不是部分。</p> <p>这是您通过 <pre><code>return view('path.to.view');</code></pre> 提供服务的页面 布局不是页面,否则您将提供布局。此页面现在可以定义(但不是必须)它扩展的布局以及它覆盖该布局的哪些部分,<pre><code>title</code></pre> 和 <pre><code>content</code></pre>。</p> </answer> </body></html>
问题描述
投票:0
回答:0
laravel
laravel-blade
最新问题
使用Stripe Payment Links进行定期付款时如何防止重复客户?
NextJS 14 SSR - 在初始渲染后添加到列表客户端
使用 ExtJS 4 单击网格中的相关数据时突出显示图表中的条形
根据编译时常量参数运行不同的函数
深度学习_我的 U-Net 模型不断出现通道错误不匹配问题
找到两个用户定义数字的最大公因数和因数对
如何识别 Android Studio LogCat 中资源 ID 0x00000000 无效的根本原因
对数据框在一列中升序排列,在另一列中降序排列
如何更新 AWS sagemaker >= 2.0 中的现有模型
Environment.SystemDirectory 可以返回什么值?
BigQuery 在 JSON 对象的 JSON 数组中提取一个属性
如何配置Docker在Ubuntu服务器上使用特定目录存储数据?
如何在一个命令行中找到rpm包中的文件并复制它?
我需要帮助,如何显示一个类中具有 java 中其他类的属性的对象? [已关闭]
如何初始化initializer_list?
PyQt5 如何将 pyuic5 生成的 Python 类添加到 QStackedWidget 中?
如果“framework.test”配置未设置为 true,则无法创建功能测试中使用的客户端
在 Docker Compose 文件中定义环境变量时出现问题
Langchain、Ollama、Llama 3提示及响应
创建目录时权限被拒绝以及如何为目录中的每个文件添加.exe后缀
© www.soinside.com 2019 - 2024. All rights reserved.