Php 从另一个页面打开模态Laravel
我正在从事laravel项目,我有很多模态,我将在我的项目中使用,所以我决定把模态代码放在另一个文件夹中。 我的视图代码是Php 从另一个页面打开模态Laravel,php,html,laravel,modal-dialog,bootstrap-4,Php,Html,Laravel,Modal Dialog,Bootstrap 4,我正在从事laravel项目,我有很多模态,我将在我的项目中使用,所以我决定把模态代码放在另一个文件夹中。 我的视图代码是 <button type="button" class="btn btn-success" data-toggle="modal" data- target="#AddUserMoodal"><i class="fa fa-edit" aria-hidden="true"></i> 当我按下这个按钮时,我想打开modals
<button type="button" class="btn btn-success" data-toggle="modal" data-
target="#AddUserMoodal"><i class="fa fa-edit" aria-hidden="true"></i>
当我按下这个按钮时,我想打开modals文件夹中的AddModal
这是/modals/addmodal.blade.php的代码
<div id="addModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
<form class="form-horizontal" role="form">
<div class="form-group">
<label class="control-label col-sm-2" for="title">Title:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="title_add" autofocus>
<small>Min: 2, Max: 32, only text</small>
<p class="errorTitle text-center alert alert-danger hidden"></p>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="content">Content:</label>
<div class="col-sm-10">
<textarea class="form-control" id="content_add" cols="40" rows="5"></textarea>
<small>Min: 2, Max: 128, only text</small>
<p class="errorContent text-center alert alert-danger hidden"></p>
</div>
</div>
</form>
<div class="modal-footer">
<button type="button" class="btn btn-success add" data-dismiss="modal">
<span id="" class='glyphicon glyphicon-check'></span> Add
</button>
<button type="button" class="btn btn-warning" data-dismiss="modal">
<span class='glyphicon glyphicon-remove'></span> Close
</button>
</div>
</div>
</div>
</div>
</div>
&时代;
标题:
最小值:2,最大值:32,仅文本
内容:
最小值:2,最大值:128,仅文本
添加
接近
但是我不知道该怎么做。它的路线是什么呢?看一看
旁注:
仅供参考,在拉雷维尔的旧版本中,您可以这样解决它:
// routes.php (which is web.php now)
Route::get('view-component/{name}', function ($name) {
return view($name);
});
// In your view
{{ route('view-component/user-form') }}
您只需要将刀片文件包含在
@include('path.to.your.blade')
您可以将HTML结构分成多个部分,只需如上所述将它们包括在内
查看刀片服务器的Laravel文档:假设您位于主页:
home.blade.php
,请使用include
<body>
@include('models/addmodal')
</body>
@包括('models/addmodal')
如果您的模态是动态的,并且希望将数据传递给模态:
<body>
@include('models/addmodal',['title'=>$title,'data'=>$data])
</body>
@包括('models/addmodal',['title'=>$title,'data'=>$data])
在你的生活中
<div id="addModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
{{$title}}
</div>
</div>
</div>
</div>
{{$title}}
如果您的代码/组件位于文件夹/resources/views/modals/addmodal.blade.php
中,您可以通过@include('modals.addmodal')
或@component('modals.addmodal')
来访问它,而不是models/